How to populate Tree View Widget
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 7
- Joined: Tue Jan 21, 2020 11:50 pm
How to populate Tree View Widget
Hi I am completely new to Livecode,
I am trying to populate a tree view widget using folder structure from disc
User chooses the folder
I create an array from folder data
I have no problem populating a field eg. scrollable list
When i try to populate the tree view widget,
put arrayData into widget "treeview"
Error states that
(Chunk: destination is not a container)
What is the usual method to change the array data within the widget??
Thanks
I am trying to populate a tree view widget using folder structure from disc
User chooses the folder
I create an array from folder data
I have no problem populating a field eg. scrollable list
When i try to populate the tree view widget,
put arrayData into widget "treeview"
Error states that
(Chunk: destination is not a container)
What is the usual method to change the array data within the widget??
Thanks
Re: How to populate Tree View Widget
Hi.
I don't use widgets, nor do I use LiveCode Builder. So why am I here?
Oh yes, Back in ordinary LC, I would surmise that you cannot put data into a widget, just as, perhaps, you cannot put data into, say, a card.They are not containers. This is pure conjecture.
Someone will answer soon.
You are welcome.
Craig
I don't use widgets, nor do I use LiveCode Builder. So why am I here?
Oh yes, Back in ordinary LC, I would surmise that you cannot put data into a widget, just as, perhaps, you cannot put data into, say, a card.They are not containers. This is pure conjecture.
Someone will answer soon.
You are welcome.
Craig
Last edited by dunbarx on Wed Jan 22, 2020 2:48 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to populate Tree View Widget
arrayData is the name of the widget property you'll be setting. Given an array named "MyArray", try this:
Code: Select all
set the arrayData of widget "treeview" to MyArray[/p]
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 7
- Joined: Tue Jan 21, 2020 11:50 pm
Re: How to populate Tree View Widget
this is my full command code:
command populateView
repeat with x = 1 to 4
put random(1000) into tArray[x]
end repeat
combine tArray using return and tab
set the arrayData of widget "treeview" to tArray
end populateView
it's still not working, I can print out my array in answer fine, just nothing changes in the arrayData field of the widget
any idea what I'm doing wrong?
command populateView
repeat with x = 1 to 4
put random(1000) into tArray[x]
end repeat
combine tArray using return and tab
set the arrayData of widget "treeview" to tArray
end populateView
it's still not working, I can print out my array in answer fine, just nothing changes in the arrayData field of the widget
any idea what I'm doing wrong?
Re: How to populate Tree View Widget
Why are you combining the array you create, when you are setting arrayData to it?combine tArray using return and tab
set the arrayData of widget "treeview" to tArray
I could be wrong, but I think you only combine array data to show it in an ordinary field.

Re: How to populate Tree View Widget
HI Theo,
welcome to the forum!
You had it right, but then wrecked it.
This will do:
Best
Klaus
welcome to the forum!
You had it right, but then wrecked it.

This will do:
Code: Select all
...
repeat with x = 1 to 4
put random(1000) into tArray[x]
end repeat
## TREEVIES widget NEEDS an ARRAY, so do not destroy the array again!
## combine tArray using return and tab
set the arrayData of widget "treeview" to tArray
...
Klaus
Re: How to populate Tree View Widget
Bogs.
You are mostly right. The "combine" command changes an array variable into an ordinary variable, the only kind that can be displayed in a field, or in almost any container one wants to actually look at.
The inspector (when viewing custom properties) and the debugger (when stepping through a handler) will elucidate arrays into visible form.
Craig
You are mostly right. The "combine" command changes an array variable into an ordinary variable, the only kind that can be displayed in a field, or in almost any container one wants to actually look at.
The inspector (when viewing custom properties) and the debugger (when stepping through a handler) will elucidate arrays into visible form.
Craig
Re: How to populate Tree View Widget
The editor has a function scripted to break down an array in the older versions of the IDE as you can see below (not sure about the current one as I tend not to go into it too often). ...and I suspect the field showing the custom property is similarly broken down *for display purposes*.
The only reason I know of for breaking down an array is therefore to display it in a field, what other reason would you have? For putting individual parts of the array into regular variables? You can already access the individual parts directly from the array

I can't imagine a caption for a button requiring an array to be listed, nor a graphic, you sure can't play a tune with one (well, maybe you could, but there are easier ways), but maybe my imagination just isn't up to the task anymore either heh.
In any case, you certainly would not to pass the broken down parts to another function that is expecting to handle an array, I don't think


Re: How to populate Tree View Widget
Bogs.
Not sure I am seeing what you mean in the SE snapshot you posted. The SE creates a black inverted triangle to mark an array. I meant something like this:
Craig
Not sure I am seeing what you mean in the SE snapshot you posted. The SE creates a black inverted triangle to mark an array. I meant something like this:
Craig
Re: How to populate Tree View Widget
The code snapshot posted is what (in the older IDEs) breaks an array down so it can be displayed in this particular group (which may look familiar


Re: How to populate Tree View Widget
OK, similar to what we have now.
In the current PI:
I use these "tools" all the time to see arrays, as opposed to changing them into ordinary variables and displaying, er, ordinarily.
Craig
In the current PI:
I use these "tools" all the time to see arrays, as opposed to changing them into ordinary variables and displaying, er, ordinarily.
Craig
Re: How to populate Tree View Widget
Myself as well, mostly to make sure I am creating and populating an array the way I expect it to be. Well, mostly the debugger, unless I am in very early versions of Mc.
