Action when selecting Leaf on Treeview

Discuss GUI programming with the RapaGUI plugin here
Post Reply
Yvan_Amiga
Posts: 10
Joined: Mon Mar 14, 2022 5:05 pm

Action when selecting Leaf on Treeview

Post by Yvan_Amiga »

I am an absolute beginner with RapaGUI and stuck.

The script below creates a Treeview and should be a Task Manager showing open and closed tasks. At least when I'm through with programming.
I'm reading the tasks from a SQLite DB and then write each task in a Leaf of a treeview.

This works. But now I want to write the details of a task into a text field when I select the leaf of this task.
So by selecting a leaf with the mouse I want the script to know which leaf has been selected and that it just has been selected.

As far as I understood I should do something like:

found, t = moai.DoMethod("tv", "GetEntry", Active, Active)
If found Then DebugPrint("Active") ; that line is just for testing


It just doesn't work. I have no idea where to place this method and if this is the correct way to do it.

Here my code snippets

Code: Select all


/****************************************************************
**                                                             **
** Name:        Formular Taskmanager                           **
** Author:      Yvan Gutknecht                                 **
** Version:     1.0                                            **
** Date:        15.04.22                                       **
** Interpreter: Hollywood 9.0                                  **
** Function:    Task Manager                                   **
**                                                             **
****************************************************************/

/*
** Make sure we have at least Hollywood 9.0!
*/
@VERSION 9,0


/*
** Enable DPI-awareness so that our GUI looks sharp even on high DPI monitors
*/
@OPTIONS {DPIAware = True}


/*
** This script requires the RapaGUI plugin
*/
@REQUIRE "RapaGUI"
@REQUIRE "sqlite3"
strDatabase = "C:/Users/yvang/Documents/relec/Programmierung/Hollywood/TaskManager/database/TaskManager.db"


TaskManagerDB=sqlite3.open(strDatabase)  

sqlite3.open(strDatabase )   





/*
** Information about this app
*/
@APPTITLE "Task Manager"
@APPVERSION "$VER: Weight 1.0 (15.04.22)"
@APPCOPYRIGHT "(C) 2022 Yvan Gutknecht"
@APPAUTHOR "Yvan Gutknecht"


/*
** Our XML GUI definition
*/
@FILE 1, "configfiles/TaskManager2.xml"


/*
** Handles all incoming events
*/
Function p_EventFunc(msg)

...

EndFunction

; dynamically create GUI from an external *.xml file definition
moai.CreateApp(ReadString(1))
i = 0;



; listen to these events!
InstallEventHandler({RapaGUI = p_EventFunc})

moai.DoMethod("tv", "open", "root", True)

;open Tasks

i =0
For a1,a2,a3,a4,a5,a6 In TaskManagerDB:urows("SELECT WAL_Wahl_Zahl,PEN_Titel,PEN_Datum ,PEN_Zeit,(SELECT WAL_Wahl_Text FROM TBL_Wahl WHERE WAL_Kategorie = WAL_ID), PEN_Erledigt FROM TBL_Wahl W JOIN TBL_Pendenz P on P.WAL_Prioritaet = W.WAL_ID WHERE PEN_Erledigt=0")
     
    moai.DoMethod("tv", "insertleaf", i, "open", "taskopen", a1, a2, a3, a4, a5)
    i = i +1
Next

;Closed Tasks

For a1,a2,a3,a4,a5,a6 In TaskManagerDB:urows("SELECT WAL_Wahl_Zahl,PEN_Titel,PEN_Datum ,PEN_Zeit,(SELECT WAL_Wahl_Text FROM TBL_Wahl WHERE WAL_Kategorie = WAL_ID), PEN_Erledigt FROM TBL_Wahl W JOIN TBL_Pendenz P on P.WAL_Prioritaet = W.WAL_ID WHERE PEN_Erledigt<>0")


    moai.DoMethod("tv", "insertleaf", i, "closed", "taskclosed", a1, a2, a3, a4, a5)

    i = i +1

Next


; main loop!
Repeat
	WaitEvent
Forever
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Action when selecting Leaf on Treeview

Post by airsoftsoftwair »

Here's an example from my test suite. It demonstrates how to listen to Treeview.Active. Note that "(none)" as the active item simply means that the active item doesn't have an id. In that case you need to give the item an id in the XML or when inserting it.

The XML:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	
	<window title="Listtree demo">
		<vgroup>
			<treeview id="listtree" width="600" height="400" notify="active">
				<column/> 

				<node id="cpu" name="CPU">
      					<leaf><item>Model: Motorola MPC 7447/7457 Apollo V1.1</item></leaf>
					<leaf><item>CPU speed: 999 Mhz</item></leaf>
					<leaf><item>FSB speed: 133 Mhz</item></leaf>
					<leaf><item>Extensions: performancemonitor altivec</item></leaf>
				</node>				
				<node name="Machine" id="machine">			
					<leaf><item>Machine name: Pegasos II</item></leaf>
					<leaf><item>Memory: 524288 KB</item></leaf>
					<leaf><item>Extensions: bus.pci bus.agp</item></leaf>
				</node>
				<node name="Expansion buses">
					<node name="PCI/AGP">
						<leaf><item>Vendor 0x11AB Device 0x6460</item></leaf>
					</node>
				</node>
				<node id="libs" name="Libraries">
					<leaf><item>0x6c7d4a58: exec.library V53.34</item></leaf>
				</node>
				<node name="Devices">
					<leaf><item>0x6ff8fba4: ramdrive.device V52.6</item></leaf>
				</node>
				<node id="tasks" name="Tasks">
					<node id="idev" name="input.device">
						<leaf id="stack"><item>Stack: 0x6ff4b000 - 0x6ff5b000</item></leaf>
						<leaf id="signals"><item>Signals: SigWait 0x00000000</item></leaf>
						<leaf id="state"><item>State: Task (Waiting)</item></leaf>
					</node>
					<node id="idev2" name="input.device 2">
						<leaf><item>Stack: 0x6ff4b000 - 0x6ff5b000</item></leaf>
						<leaf><item>Signals: SigWait 0x00000000</item></leaf>
						<leaf><item>State: Task (Waiting)</item></leaf>
					</node>	
					<node id="idev3" name="input.device 3">
						<leaf><item>Stack: 0x6ff4b000 - 0x6ff5b000</item></leaf>
						<leaf><item>Signals: SigWait 0x00000000</item></leaf>
						<leaf><item>State: Task (Waiting)</item></leaf>
					</node>	
					<node id="idev4" name="input.device 4">
						<leaf><item>Stack: 0x6ff4b000 - 0x6ff5b000</item></leaf>
						<leaf><item>Signals: SigWait 0x00000000</item></leaf>
						<leaf><item>State: Task (Waiting)</item></leaf>
					</node>															
				</node>
			</treeview>
		</vgroup>	
	</window>
</application>
The Hollywood code:

Code: Select all

@REQUIRE "RapaGUI"

@APPTITLE "Listtree"
@APPVERSION "$VER: Listtree 1.0 (30.12.12)"
@APPCOPYRIGHT "©2012, Andreas Falkenhahn"
@APPAUTHOR "Andreas Falkenhahn"
@APPDESCRIPTION "Shows listtree MCC."

Function p_EventFunc(msg)

	Switch msg.action
	Case "RapaGUI":
		Switch msg.attribute
		Case "Active":
			DebugPrint(msg.attribute, msg.triggervalue)
		Default:
			DebugPrint(msg.attribute, msg.id, msg.triggervalue)				
 		EndSwitch
	EndSwitch

EndFunction

; dynamically create MUI GUI from an external *.xml file definition
moai.CreateApp(FileToString("Listtree.xml"))

; listen to these events!
InstallEventHandler({RapaGUI = p_EventFunc})

; main loop!
Repeat
	WaitEvent
Forever
Yvan_Amiga
Posts: 10
Joined: Mon Mar 14, 2022 5:05 pm

Re: Action when selecting Leaf on Treeview

Post by Yvan_Amiga »

Thank you Andreas
As I see you don't use DoMethod at all and it does exactly what I was looking for. I could have searched for a long time by myself.
Post Reply