Code: Select all
@DISPLAY {Hidden = True}
@REQUIRE "MUIRoyale"
Function p_CompareFunc(msg)
DebugPrint("E1: "..Unpack(msg.entry1)) ; Table 1
DebugPrint("E2: "..Unpack(msg.entry2)) ; Table 2
;DebugPrint(msg.entry1[0].." - "..msg.entry2[0])
Local myVal = 0
Local sortdir = mui.get("txsort","Contents")
DebugPrint("sortdir: "..sortdir)
If (sortdir = "bt2")
If msg.entry1[0] > msg.entry2[0] Then myVal = 1
If msg.entry1[0] < msg.entry2[0] Then myVal = -1
EndIf()
If(sortdir = "bt1")
If msg.entry1[0] > msg.entry2[0] Then myVal = -1
If msg.entry1[0] < msg.entry2[0] Then myVal = 1
EndIf()
DebugPrint("Val: "..myVal)
Return(Val)
EndFunction
Function p_EventFunc(msg)
DebugPrint("Event:", "I:", msg.ID,"A:", msg.Attribute,"T:", msg.TriggerValue, "C:", msg.Class)
Switch msg.action
Case "MUIRoyale":
Switch msg.attribute
Case "CloseRequest":
End
Case "Pressed":
Switch msg.ID
Case "bt1":
mui.set("txsort","Contents","bt1")
mui.DoMethod("lv", "sort", 0)
Case "bt2":
mui.set("txsort","Contents","bt2")
mui.DoMethod("lv", "sort", 0)
Case "bt3":
mui.DoMethod("lv", "Exchange", 0, 1)
mui.DoMethod("lv", "Exchange", 3, 5)
mui.DoMethod("lv", "Exchange", 7, 0)
EndSwitch
EndSwitch
EndSwitch
EndFunction
mui.CreateGui(FileToString("customsort.xml"))
InstallEventHandler({MUIRoyale = p_EventFunc})
Repeat
WaitEvent
Forever
XML:
Code: Select all
<application base="testapp" id="app">
<window title="Sort" id="win" muiid="HSMW" notify="closerequest" userightborderscroller="true" usebottomborderscroller="false">
<vgroup>
<listview id="lv" sortfunc="p_comparefunc" notify="sortfunc">
<column>
<item>Eins</item><item>Zwei</item><item>Drei</item>
<!--<item>Vier</item>
<item>Fünf</item><item>Sechs</item><item>Sieben</item><item>Acht</item><item>Neun</item><item>Zehn</item>
-->
</column>
</listview>
<button id="bt1" notify="pressed">Sort!</button>
<button id="bt2" notify="pressed">SortRev!</button>
<button id="bt3" notify="pressed">Mix</button>
<text id="txsort" hide="true"></text>
</vgroup>
</window></application>
Here it bt1 and bt2 lead to ascending sorted listview...