I am trying to get the the parent of the node that is "Active" but I get two levels up.
Here is my simple code to show the issue.
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateApp([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application>
<window title="Test" id="main" notify="closerequest" width="200">
<vgroup>
<treeview id="tree">
<column/>
<node name="Level 1">
<node name="Level 2">
<node name="Level 3">
</node>
<node name="Level 4">
<node name="Level 5">
</node>
</node>
</node>
</node>
<node name="Category 1">
<node name="Category 2">
<node name="Category 3">
</node>
</node>
</node>
</treeview>
<text id="name"></text>
<hgroup>
<button id="parent"> Parent </button>
<button id="quit"> Quit </button>
</hgroup>
</vgroup>
</window>
</application>
]])
Function p_EventFunc(msg)
Switch msg.action
Case "RapaGUI":
Switch msg.attribute
Case "Pressed":
Switch msg.id
Case "quit"
End
Case "parent"
Local Found, p = moai.DoMethod("tree", "GetEntry", "Active", "Parent")
If Found = 1
Parent$, B$ ,C$ = unpack(p.items)
moai.Set("name", "Text", unpack(p.items))
Else
moai.Set("name", "Text", " At Root Level ")
Endif
EndSwitch
Case "CloseRequest"
Switch msg.id
Case "main"
End
EndSwitch
EndSwitch
EndSwitch
EndFunction
InstallEventHandler({RapaGUI = p_EventFunc})
Repeat
WaitEvent
Forever
Does any one know how I can get the next level up, and can correct my code.
Thank
Leo