Page 1 of 1

help needed on treeview setitem

Posted: Fri Oct 02, 2020 1:19 pm
by ilbarbax
I have a treeview where I prepared a dialog to edit the different fields and when I try to save the updated data only the first field is updated and not the subsequent ones.
Probably I do something wrong. Help please.

This is part of the XML involved:

Code: Select all

					<treeview id="tv" editablenodes="true">
						<column title="Item" editable="true"/>
						<column title="ID" editable="true"/>
						<column title="shortcut" editable="true"/>
						<column title="Help" editable="true"/>
						<column title="Disabled" checkbox="true"/>
This is the code to save the data in the existing field

Code: Select all

					Local a_a=moai.Get("tv", "active")										
					moai.DoMethod(a_a, "SetItem", 0, moai.Get("ptv_Item","text"))					
					moai.DoMethod(a_a, "SetItem", 1, moai.Get("ptv_ID","text"))					
					moai.DoMethod(a_a, "SetItem", 2, moai.Get("ptv_Scut","text"))					
					moai.DoMethod(a_a, "SetItem", 3, moai.Get("ptv_Help","text"))					
					moai.DoMethod(a_a, "SetState", 4, moai.Get("ptv_disab","selected"))

Re: help needed on treeview setitem

Posted: Sun Oct 04, 2020 1:00 pm
by airsoftsoftwair
Looks correct. Please post a minimal, complete, and verifiable example (MCVE) and I'll take a look.

Re: help needed on treeview setitem

Posted: Mon Oct 05, 2020 4:56 pm
by ilbarbax
Here you are

File test1.xml

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="EasyRapa">
		
		
	<window id="win"  width="800" height="600" >
		<vgroup>
			<treeview id="tv" editablenodes="true">
				<column title="Item" editable="true"/>
				<column title="ID" editable="true"/>
				<column title="shortcut" editable="true"/>
				<column title="Help" editable="true"/>
				<column title="Disabled" checkbox="true"/>
				
				<node name="My Menu" id="tv_my_Menu">
					<node name="File" id="mn_n_File">
						<leaf id="mn_i_open">
							<item>Open</item>
							<item>mn_open</item>
							<item>Ctrl+O</item>
							<item>Open a new project</item>
							<item>False</item>
						</leaf>
						<leaf id="mn_i_close">
							<item>Close</item>
							<item>mn_close</item>
							<item></item>
							<item>Close project</item>
							<item>True</item>
						</leaf>						
					</node>
				</node>
			</treeview>
			<hgroup>
				<button id="mn_Ok">Test</button>
			</hgroup>	
			
		</vgroup>
	</window>
File test1.hws

Code: Select all

@REQUIRE "RapaGUI", {Version = 1, Revision = 2}
	
Function p_test(msg)
	Switch msg.action
	Case "RapaGUI":
		Local a_a=moai.Get("tv", "active")										
		moai.DoMethod(a_a, "SetItem", 0, "aaaaa")					
		moai.DoMethod(a_a, "SetItem", 1, "bbbbb")					
		moai.DoMethod(a_a, "SetItem", 2, "ccccc")					
		moai.DoMethod(a_a, "SetItem", 3, "ddddd")					
		moai.DoMethod(a_a, "SetState", 4,True)
	EndSwitch										

	
EndFunction

moai.CreateApp(FileToString("test1.xml"))

InstallEventHandler({RapaGUI = p_test})

Repeat
	 WaitEvent
Forever

Re: help needed on treeview setitem

Posted: Wed Oct 07, 2020 6:42 pm
by airsoftsoftwair
Thanks, which platforms have you tested this on?

Re: help needed on treeview setitem

Posted: Thu Oct 08, 2020 9:26 am
by ilbarbax
Windows 7 64

Re: help needed on treeview setitem

Posted: Thu Oct 08, 2020 11:48 am
by airsoftsoftwair
Right, thanks for reporting this major issue!

Code: Select all

- Fix [Windows/macOS/Linux]: Treeviewleaf.SetItem() was only able to change the text of items in the first column