Re: Listview Column Hide
Posted: Fri Oct 11, 2024 3:11 pm
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:
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:
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
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()
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
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