Treeview GetEntry result have no name tag

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

Treeview GetEntry result have no name tag

Post by lazi »

It seems to me that according to the guide the Treeview.GetEntry method should give back a name tag in the result, but I always get an error like: Table filed "name" was not initialised!

Here is the modified Treeview.hws example where I added a Dump button linked to the p_DumpListTree() function from the rapaGUI guide.

Code: Select all

/****************************************************************
**                                                             **
** Name:        Treeview                                       **
** Author:      Andreas Falkenhahn                             **
** Version:     1.0                                            **
** Date:        13.05.16                                       **
** Interpreter: Hollywood 6.1                                  **
** Licence:     Sample program                                 **
** Function:    Demonstrates how to create a treeview with     **
**              multiple columns                               **
**                                                             **
** History:                                                    **
**                                                             **
** 1.0: (13.05.16)                                             **
** - initial release                                           **
**															   **
** 1.1: added p_DumpTreelist() to a Dump button                **
**                                                             **
****************************************************************/

/*
** Make sure we have at least Hollywood 6.1!
*/
@VERSION 6,1


/*
** This script requires the RapaGUI plugin
*/
@REQUIRE "RapaGUI"


/*
** Information about this app
*/
@APPTITLE "Treeview"
@APPVERSION "$VER: Treeview 1.0 (13.05.16)"
@APPCOPYRIGHT "(C) 2016 by Andreas Falkenhahn"
@APPAUTHOR "Andreas Falkenhahn"
@APPDESCRIPTION "Demonstrates how to create a treeview with multiple columns"


/*
** Handles all incoming events
*/
Function p_EventFunc(msg)
	
	Switch msg.action
	Case "RapaGUI":
		Switch msg.attribute
		Case "Pressed":
			Switch msg.id
			Case "select":
				moai.Set("tv", "active", "ninth")
			Case "expand":
				moai.DoMethod("tv", "open", "active", True)
			Case "collapse":
				moai.DoMethod("tv", "close", "active")
			Case "mozart":
				If (Not mozartadded) And moai.HaveObject("classical") And moai.HaveObject("brahms")
					moai.DoMethod("tv", "insertleaf", "mozart2", "classical", "brahms", "Eine kleine Nachtmusik", "Wolfgang Amadeus Mozart", "1787", "good", "80%")	
					mozartadded = True
				EndIf	
			Case "delete":
				moai.DoMethod("tv", "remove", "active")	
			Case "clear":
				moai.Set("tv", "active", "off")	
			Case "dump":
				p_DumpListTree("tv", "root", 0)
			EndSwitch										
 		EndSwitch
	EndSwitch

EndFunction

Function p_DumpListTree(id$, node, indent)
   Local found, t = moai.DoMethod(id$, "GetEntry", node, "Head")
   While found = True
      If indent > 0
         DebugPrint(RepeatStr(" ", indent) ..
             IIf(t.Node = True, "+", "") .. t.name)
      Else
         DebugPrint(IIf(t.Node = True, "+", "") .. t.name)
      EndIf
      If t.Node = True Then p_DumpListTree(id$, t.uid, indent + 4)
      found, t = moai.DoMethod(id$, "GetEntry", t.uid, "Next")
    Wend
EndFunction



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

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

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

; main loop!
Repeat
	WaitEvent
Forever                            
And the modified xml:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
					
	<window id="win" title="Treeview" height="400">
		<vgroup>
			<treeview id="tv">
				<column title="title"/>
				<column title="artist"/>
				<column title="year"/>
				<column title="rating"/>
				<column title="popularity"/>
				
				<node name="My music">
					<node name="Pop music">
						<leaf>
							<item>You are not alone</item>
							<item>Michael Jackson</item>
							<item>1995</item>
							<item>good</item>
							<item>80%</item>
						</leaf>
						<leaf>
							<item>Take a bow</item>
							<item>Madonna</item>
							<item>1994</item>
							<item>good</item>
							<item>80%</item>
						</leaf>						
					</node>
					
					<node name="Classical music" id="classical">
						<leaf id="ninth">
							<item>Ninth Symphony</item>
							<item>Ludwig van Beethoven</item>
							<item>1824</item>
							<item>good</item>
							<item>80%</item>				
						</leaf>
						
						<leaf id="brahms">
							<item>German Requiem</item>
							<item>Johannes Brahms</item>
							<item>1868</item>
							<item>good</item>
							<item>80%</item>
						</leaf>												
					</node>		
				</node>
			</treeview>
			
			<hgroup>
				<button id="mozart">Add Mozart</button>
				<button id="delete">Delete selected</button>
				<button id="select">Select Ninth Symphony</button>
				<button id="collapse">Collapse</button>
				<button id="expand">Expand</button>
				<button id="clear">Clear selection</button>
				<button id="dump">Dump</button>
			</hgroup>	
		</vgroup>
	</window>
</application>       

User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Treeview GetEntry result have no name tag

Post by airsoftsoftwair »

Oops, that's a bug in the documentation. Treeview.GetEntry() returns a table named "items" which contains as many strings as there are columns in your treeview for leaves and just one string for nodes because nodes always occupy the first column. The "name" tag is a leftover from the MUI Royale documentation I guess :)
Post Reply