Listview Column Hide

Discuss GUI programming with the RapaGUI plugin here
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Listview Column Hide

Post by jPV »

You have an eternal notify loop there, no wonder it runs out of stack. I don't know if MUI handles this kind of flood somehow on other platforms. But in any case in your SortColumn event handling you trigger the SortColumn notification again, which loops forever then. A solution is to disable notification there like this:

Code: Select all

       ElseIf(msg.attribute = "SortColumn")
          If(msg.triggervalue = 3)
             moai.set("lvTankstellen","SortColumn",3, "nonotify", True)
             moai.set("lvTankstellenHidden","SortColumn",3)
          ElseIf(msg.triggervalue = 4)
             moai.set("lvTankstellen","SortColumn",4, "nonotify", True)
             moai.set("lvTankstellenHidden","SortColumn",4)       
          EndIf() 
But you're also doing certain things for nothing, and it doesn't seem to work as intended after fixing the stack issue either.

I started to test for a simplier solution like this:

Code: Select all

@REQUIRE "RapaGUI"
moai.CreateApp([[<?xml version="1.0" encoding="utf-8"?>
<application id="app">
	<window title="ListviewStack" height="Screen:60" width="Screen:60">
	  <vgroup>     
          <vgroup frame="true" id="ListTankstellen" title="Tankstellenliste" weight="900">
		<listview id="lvTankstellen" notify="doubleclick;ClickColumn;SortColumn" alternate="true">
                  <column title="Marke"/>
                  <column title="offen" checkbox="true"/>
                  <column title="Adresse"/>
		  <column title="Preis" sortable="true" notify="sortorder" id="lvTankstellenPreis"/>
                  <column title="Entfernung" sortable="true" notify="sortorder" id="lvTankstellenEntf"/>                  
                </listview>
          </vgroup>               
          <vgroup frame="true" id="ListTankstellenHidden" weight="900">
                <listview id="lvTankstellenHidden">
                  <column title="Marke"/>
                  <column title="offen" checkbox="true"/>
                  <column title="Adresse"/>
		  <column title="Preis" sortable="true" id="lvTankstellenPreisHidden"/>
		  <column title="Entfernung" sortable="true" id="lvTankstellenEntfHidden"/>
                  <column title="lat" />
                  <column title="long" />
                </listview>
          </vgroup>                      
      </vgroup>
	</window>
</application>
]])

Function p_EventFunc(msg)
	Switch msg.action
	Case "RapaGUI":
		Switch msg.id
		 Case "blabla":

		 Default:
			If StartsWith(msg.id, "lvTankstellen") Then p_HandleListview(msg)
         EndSwitch
	EndSwitch
EndFunction

Function p_PrepareData()
    moai.DoMethod("lvTankstellen", "Clear")
    moai.DoMethod("lvTankstellenHidden", "Clear")
    moai.Set("ListTankstellen","Hide",False)
    For Local i = 0 To 3
        moai.DoMethod("lvTankstellen", "Insert",i,i,i,i, i, i)
        moai.DoMethod("lvTankstellenHidden", "Insert",i,i,i,i, i, i,i,i)
    Next
    moai.DoMethod("lvTankstellen", "Sort")
    moai.DoMethod("lvTankstellenHidden", "Sort")
EndFunction

function p_HandleListview(msg)
	If HaveItem(msg,"attribute")
		If msg.attribute = "SortOrder"
			moai.Set(msg.id .. "Hidden", "SortOrder", msg.TriggerValue)
			moai.Set("lvTankstellenHidden", "SortColumn", 0) ; A work-around because the following line doesn't do anything.
			;moai.DoMethod("lvTankstellenHidden", "Sort")
		ElseIf msg.attribute = "DoubleClick"
			p_ViewGasStationDetails()
		ElseIf msg.attribute = "SortColumn"
			moai.Set("lvTankstellenHidden", "SortColumn", msg.TriggerValue)
		Else
			DebugPrint("!!!", msg.attribute)
		EndIf
	EndIf
EndFunction

InstallEventHandler({RapaGUI = p_EventFunc})
p_PrepareData()

Repeat
	WaitEvent
Forever
But I found that Listview.Sort doesn't seem to work at all? Had to figure out a work-around for it...

Andreas, do you think the Listview.Sort should work when used like this?

Code: Select all

@REQUIRE "RapaGUI"
moai.CreateApp([[<?xml version="1.0" encoding="utf-8"?>
<application id="app">
       <window title="ListviewStack" height="Screen:60" width="Screen:60">
	  <vgroup>     
          <vgroup frame="true" id="ListTankstellen" title="Tankstellenliste" weight="900">
		<listview id="lvTankstellen" alternate="true">
                  <column title="Marke"/>
                  <column title="offen" checkbox="true"/>
                  <column title="Adresse"/>
		  <column title="Preis" sortable="true" id="lvTankstellenPreis"/>
		  <column title="Entfernung" id="lvTankstellenEntf"/>
                </listview>
          </vgroup>               
      </vgroup>
	</window>
</application>
]])

Function p_PrepareData()
	moai.DoMethod("lvTankstellen", "Clear")
	For Local i = 0 To 3
		moai.DoMethod("lvTankstellen", "Insert",i,i,i,i, i, i)
	Next

	moai.Set("lvTankstellenPreis", "SortOrder", "Descending")

	; This doesn't sort the list to the Descending order set above.
	moai.DoMethod("lvTankstellen", "Sort")

	Wait(100)

	; Have to kick some other action on the list to get it sorted.
	moai.Set("lvTankstellen", "SortColumn", 0)
	moai.Set("lvTankstellen", "SortColumn", 3)
EndFunction

p_PrepareData()

Repeat
	WaitEvent
Forever
GMKai
Posts: 158
Joined: Mon Feb 15, 2010 10:58 am

Re: Listview Column Hide

Post by GMKai »

Code: Select all

       /*ElseIf(msg.attribute = "SortColumn")
	  If(msg.triggervalue = 3)
	     moai.Set("lvTankstellen","SortColumn",3)
	     moai.Set("lvTankstellenHidden","SortColumn",3)
	  ElseIf(msg.triggervalue = 4)
	     moai.Set("lvTankstellen","SortColumn",4)
	     moai.Set("lvTankstellenHidden","SortColumn",4)       
  EndIf()
*/
ommiting the above snippet makes the little example run again, but still way to go to have it fully working with MorphOS and MUI
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Listview Column Hide

Post by jPV »

GMKai wrote: Tue Oct 15, 2024 1:41 pm but still way to go to have it fully working with MorphOS and MUI
Does the full code in the middle of my previous reply work on your setup? I think it should work as you wanted, if I understood what you're after.
GMKai
Posts: 158
Joined: Mon Feb 15, 2010 10:58 am

Re: Listview Column Hide

Post by GMKai »

yes it does!

will check out the differences
Post Reply