Treeview GetEntry result have no name tag

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
Posts: 549
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!

** This script requires the RapaGUI plugin

** 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":
			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
			Case "delete":
				moai.DoMethod("tv", "remove", "active")	
			Case "clear":
				moai.Set("tv", "active", "off")	
			Case "dump":
				p_DumpListTree("tv", "root", 0)


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, "+", "") ..
         DebugPrint(IIf(t.Node = True, "+", "") ..
      If t.Node = True Then p_DumpListTree(id$, t.uid, indent + 4)
      found, t = moai.DoMethod(id$, "GetEntry", t.uid, "Next")

; dynamically create GUI from an external *.xml file definition

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

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

; main loop!
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">
			<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">
							<item>You are not alone</item>
							<item>Michael Jackson</item>
							<item>Take a bow</item>
					<node name="Classical music" id="classical">
						<leaf id="ninth">
							<item>Ninth Symphony</item>
							<item>Ludwig van Beethoven</item>
						<leaf id="brahms">
							<item>German Requiem</item>
							<item>Johannes Brahms</item>
				<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>

User avatar
Posts: 4196
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany

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