Pick out items in treeview
Posted: Fri Sep 01, 2017 6:33 am
I have set up a treeview of animals using RAPAGUI. Here is the MyTreeview.xml file for that
And now here is my hollywood script (MyTreeview.hws) which will run it:
What I wish to be able to do is to select a line, then click on one of the buttons at bottom to execute that particular file from the row. For that I need to be able to interrogate the entry (using GetEntry I presume) and parse it to pick out each item on the row. That will allow me to execute the particular item entry when I click on one of the buttons at the bottom. I have no idea how to do this parsing.
I have read the treeview blurb in the RAPAGUI manual but have not been able to follow the logic there (my fault I suppose, though I have done some programming in the past). Can anyone assist me as to how to parse the selected row using GetEntry? Thanks in advance.
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<window id="win" title="Treeview" height="400" width="500">
<vgroup>
<treeview id="tv">
<column title="ANIMAL FILES" width="150"/>
<column title="jpgfile" width="100"/>
<column title="pdffile" width="100"/>
<column title="docfile" width="100"/>
<node name="Pet Files">
<node name="CatFiles">
<leaf id="WildCats">
<item>Wild Cats</item>
<item>Tiger.jpg</item>
<item>Leopard.pdf</item>
<item>Panther.doc</item>
</leaf>
<leaf id="TameCats">
<item>Tame Cats</item>
<item>Ginger.jpg</item>
<item>Tonkinese.pdf</item>
<item>RagDoll.doc</item>
</leaf>
</node>
<node name="DogFiles">
<leaf id="WildDogs">
<item>Wild Dogs</item>
<item>Jackal.jpg</item>
<item>Wolf.jpg</item>
<item>Hyena.doc</item>
</leaf>
<leaf id="TameDogs">
<item>Tame Dogs</item>
<item>Labrador.jpg</item>
<item>Alsation.pdf</item>
<item>Bulldog.doc</item>
</leaf>
</node>
</node>
</treeview>
<hgroup>
<button id="viewjpg">View jpg</button>
<button id="viewpdf">View pdf</button>
<button id="viewdoc">View doc</button>
</hgroup>
</vgroup>
</window>
</application>
Code: Select all
@VERSION 6,1
@REQUIRE "RapaGUI"
Function p_EventFunc(msg)
Switch msg.action
Case "RapaGUI":
Switch msg.attribute
Case "Pressed":
Switch msg.id
Case "viewjpg":
Case "viewpdf":
Case "viewdoc":
EndSwitch
EndSwitch
EndSwitch
EndFunction
moai.CreateApp(FileToString("MyTreeview.xml"))
InstallEventHandler({RapaGUI = p_EventFunc})
moai.DoMethod("tv", "open", "root", True)
Repeat
WaitEvent
Forever
I have read the treeview blurb in the RAPAGUI manual but have not been able to follow the logic there (my fault I suppose, though I have done some programming in the past). Can anyone assist me as to how to parse the selected row using GetEntry? Thanks in advance.