Hi,

 

  In Lua use the iup.TreeSetUserId and iup.TreeGetUserId extra functions 
described at the documentation.

 

  When using those functions the USERDATAid attribute is used as you did, but 
also the Lua object is referenced in the Lua registry.

 

  From the IupTree Extra Fucntions documentation: “This means also that the 
associated object will not be garbage collected until its reference is removed. 
Also, the user should not use the same table to reference different nodes 
(neither in the same nor across different trees.)”

 

Best,

Scuri

 

From: Daniel Kollmann [mailto:[email protected]] 
Sent: domingo, 17 de junho de 2012 15:07
To: [email protected]
Subject: [Iup-users] iup 3.5 - Lua - Userdata in Tree

 

I searched the examples, internet and mailing list to find an actual example on 
how userdata is handled for trees, but with little success so far.

 

I add new nodes to my tree using myTree.addbranch0= “Hello”

 

Then I want to assign some userdata to it:

 

myTree[ “userdata”.. myTree.lastAddNode ]= { test= 7 }

 

Then when this node is selected I want to retrieve that data:

 

selection_cb= function(nodeid, selected)

        if selected then

            local userdata= myTree[ "userdata".. nodeid ]

 

        end

   end

 

I guess that I have several errors in my code but I am not sure what is wrong. 
When I look at the documentation, it does not have any obvious clues on what is 
not correct.

 

Thanks for any suggestions

Daniel

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to