Page 1 of 1
How to populate Tree View Widget
Posted: Tue Jan 21, 2020 11:57 pm
by theowright2020
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
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 12:59 am
by dunbarx
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
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 1:37 am
by FourthWorld
theowright2020 wrote: ↑Tue Jan 21, 2020 11:57 pm
put arrayData into widget "treeview"
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]
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 10:47 am
by theowright2020
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?
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 11:28 am
by bogs
combine tArray using return and tab
set the arrayData of widget "treeview" to tArray
Why are you combining the array you create, when you are setting arrayData to it?
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
Posted: Wed Jan 22, 2020 2:06 pm
by Klaus
HI Theo,
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
...
Best
Klaus
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 5:48 pm
by dunbarx
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
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 8:31 pm
by bogs
dunbarx wrote: ↑Wed Jan 22, 2020 5:48 pm
The inspector (when viewing custom properties) and the debugger (when stepping through a handler) will elucidate arrays into visible form.
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).

- Um-hummmm....
...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
Posted: Wed Jan 22, 2020 8:48 pm
by dunbarx
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
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 9:17 pm
by bogs
dunbarx wrote: ↑Wed Jan 22, 2020 8:48 pm
Not sure I am seeing what you mean in the SE snapshot you posted.
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

)

- I've got a few nuts that fell from my tree...
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 9:55 pm
by dunbarx
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
Re: How to populate Tree View Widget
Posted: Wed Jan 22, 2020 10:26 pm
by bogs
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.