Overwriting Title in List view

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

Overwriting Title in List view

Post by Yvan_Amiga »

I have the following form

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
					
	<window id="win" title="Tasks" height="800" width="900">

		<vgroup>
			<hgroup>
				<choice id="datefilter">
					<item>All</item>
					<item>Past</item>
					<item>Today</item>
					<item>Days 1 to 7</item>
					<item>Days 8 to 39</item>
					<item>Days 40 to 364</item>
					<item>Days from 365</item>
				</choice>
				<button id="applydatefilter">Apply Date filter (open tasks only)</button>

				<text id="filter">Additional Filter</text>
			</hgroup>
			<treeview id="tv" height="600" notify="active">
				<column title="Priority"/>
				<column title="Title"/>
				<column title="Due Date"/>
				<column title="Due Time"/>
				<column title="Category"/>
				
				<node id="tasks" name="My Tasks">
					<node id="open" name="Open Tasks">

					</node>
					
					<node id="closed" name="Closed Tasks">

					</node>
				</node>
			</treeview>

			<texteditor id="kommentar" notify="cursorpos;undoavailable;redoavailable;italic;bold;underline;areamarked;haschanged" styled="true" nowrap="true"/>
			<hgroup>
				<button id="newtask">New Task</button>
				<button id="edittask">Edit Task</button>
				<button id="delete">Delete selected</button>
				<button id="undo">Undo Delete/Edit</button>
			</hgroup>
			<hgroup>
				<button id="sort">Sort by</button>
				<button id="openclosed">Toggle Open/Closed</button>
				<button id="admin">Admin</button>
			</hgroup>

		</vgroup>
	</window>
</application>
I want to overwrite the text of the following line
<text id="filter">Additional Filter</text>

I tried it the following ways

first

Code: Select all

local filterText = rap.GUI.getTextById("filter")  ;-- Get the current text of the text field
filterText = "New Text"  ;-- Assign the new text
rap.GUI.setTextById("filter", filterText)  ;-- Set the new text to the text field using the assigned variable

second

Code: Select all

local win = rap.GUI.getWindowById("win")  ;-- Get the window
local filterText = win:getChildById("filter")  ;-- Get the text field
filterText:setText("New Text")  ;-- Set the new text for the text field
I always get the error message
Error in line 337 (TaskManager_WIP.hws): Table rap{} not found!

Any idea?
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Overwriting Title in List view

Post by airsoftsoftwair »

Hmm, what is "rap.GUI.getTextById" et al. anyway? Is that some custom function? It's definitely not a RapaGUI function because those start with "moai.".
Yvan_Amiga
Posts: 21
Joined: Mon Mar 14, 2022 5:05 pm

Re: Overwriting Title in List view

Post by Yvan_Amiga »

Hmm, I didn't find a way to do it in the RapaGUI plugin doc so I googled and found these code pieces.

But anyway, you asked the right question. I now found it. I was searching to far.
The following code works and replaces the text "Addional Filter' by "New Text"

Code: Select all

filterText = "New Text"  ;-- Assign the new text
moai.Set("filter", "text", filterText)  ;-- Set the new text to the text field using the assigned variable
Thank you
Post Reply