Tree view widget - assign labels to non-leaf nodes?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Fjord
Posts: 68
Joined: Sat Dec 06, 2008 6:18 pm
Location: Western Europe

Tree view widget - assign labels to non-leaf nodes?

Post by Fjord » Sat Jan 14, 2017 7:18 pm

Hi,
I'm experimenting with a tree view widget; there are some things I can't find a way to do. Help appreciated. Livecode 8.1.0.
If I do

Code: Select all

   put "first label" into p[1]
   put "second label" into p[2]
   set the arrayData of widget "tv" to p
I get both labels; but if I do

Code: Select all

   put "first label" into p[1]
   put "second label" into p[2]
   put "first sublabel of second label" into p[2][1]
   put "second sublabel of second label" into p[2][2]
   set the arrayData of widget "tv" to p
I lose the "second label".
Question 1: how can I have a label for a node that has subnodes?
Question 2: is there a way to display only the labels, not the indices which are irrelevant to the user, still retaining the triangles?
By the bye: why is it, if I delete the last subnode of a node, the latter still has a triangle which is now useless?
--
François

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3273
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Tree view widget - assign labels to non-leaf nodes?

Post by bn » Sun Jan 15, 2017 1:23 am

Hi François,

do you mean something like this:

Code: Select all

on mouseUp
   put "" into p["first label"]
   put "" into p["second label"]
   put "" into p["second label"]["first sublabel of second label"]
   put "Data1" into p["second label"]["first sublabel of second label"]
   put "" into p["second label"]["second sublabel of second label"]
   put "Data2" into p["second label"]["second sublabel of second label"]
   set the arrayData of widget "tv" to p
end mouseUp
By the bye: why is it, if I delete the last subnode of a node, the latter still has a triangle which is now useless?
I think that is a bug.

Kind regards
Bernd

Fjord
Posts: 68
Joined: Sat Dec 06, 2008 6:18 pm
Location: Western Europe

Re: Tree view widget - assign labels to non-leaf nodes?

Post by Fjord » Sun Jan 15, 2017 2:07 pm

Thank you Bernd!!
In my mind, I was focusing on what you call data and wanted to ignore the keys. But I understand; the hierarchy is in the keys and your example opened my [mind's] eyes.
--
François

Post Reply

Return to “Talking LiveCode”