Collapse and expand Tree View Widget from code
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 1
- Joined: Tue Sep 11, 2018 3:46 am
Collapse and expand Tree View Widget from code
Anybody know how to collapse a treeview widget with code?
I want to reset a treeview widget for users from within the code?
Would be even better if I had full control over what part to expand and collapse.
Regards,
Quda
I want to reset a treeview widget for users from within the code?
Would be even better if I had full control over what part to expand and collapse.
Regards,
Quda
Re: Collapse and expand Tree View Widget from code
Currently there isn't a way to change the fold state from code.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Livecode Staff Member
- Posts: 818
- Joined: Fri Feb 06, 2015 4:03 pm
Re: Collapse and expand Tree View Widget from code
You could try the following - it is not very efficient, but seems to work.
1. Find the location of the arrow you want to click so as as to expand/collapse the tree view widget. To do that, you can place the cursor over the tree arrow and type in the message box (*while the cursor is still over the arrow*):
"put the mouseloc"
This will return a pair of card coordinates, e.g. "65,121"
2. Then you can do:
"click at 65,121"
This will make the tree view to expand/collapse
PS: Make sure you are in Run mode.
Best,
Panos
--
1. Find the location of the arrow you want to click so as as to expand/collapse the tree view widget. To do that, you can place the cursor over the tree arrow and type in the message box (*while the cursor is still over the arrow*):
"put the mouseloc"
This will return a pair of card coordinates, e.g. "65,121"
2. Then you can do:
"click at 65,121"
This will make the tree view to expand/collapse
PS: Make sure you are in Run mode.
Best,
Panos
--
Re: Collapse and expand Tree View Widget from code
I think I need to do another PR to make it easier
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Livecode Staff Member
- Posts: 818
- Joined: Fri Feb 06, 2015 4:03 pm
Re: Collapse and expand Tree View Widget from code
Hehe, you are more than welcome
Re: Collapse and expand Tree View Widget from code
Similar to this, when I do a search within the Tree View I would need it to unfold to reveal where it is nested in the array when all entries are folded. Assume the element is contained four folds deep, eg
I can't get my head around how to recode the widget in LCB to unfold a particular tree element. Any clues?
Thanks
Code: Select all
Root
- Fold 1
- Fold 2
Element = Value
- Fold 3
- Fold 4
Element = Value
= Root[Fold1][Fold2][Fold3][Fold4][Element]
Thanks
Re: Collapse and expand Tree View Widget from code
Yes. I have code close to ready. I’m waiting for a merge PR to get finalized before I submit to be sure it will result in a clean merge.
The initial fix will auto-unfold on selection and provide a way to reset the fold state. Being able to collapse individual keys is going to need to wait for another PR to merge (send widget ...)
I could expose the full fold state array as a temp solution but then one would need to manually manipulate it.
The initial fix will auto-unfold on selection and provide a way to reset the fold state. Being able to collapse individual keys is going to need to wait for another PR to merge (send widget ...)
I could expose the full fold state array as a temp solution but then one would need to manually manipulate it.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Collapse and expand Tree View Widget from code
Hi Brian,
Thanks for the update. Do you have it up in a GitHub branch to view at all before you submit for PR. It may help me understand this aspect of LCB a little better.
Personally I wouldn't need to get a 'full fold state' array, though I can see why this would be handy. At the moment I just need it to unfold to reveal and highlight the selected element. I've seen your PR/Merge for the auto-scroll properties which will also be a welcome addition.
Thanks and well done.
π
Thanks for the update. Do you have it up in a GitHub branch to view at all before you submit for PR. It may help me understand this aspect of LCB a little better.
Personally I wouldn't need to get a 'full fold state' array, though I can see why this would be handy. At the moment I just need it to unfold to reveal and highlight the selected element. I've seen your PR/Merge for the auto-scroll properties which will also be a welcome addition.
Thanks and well done.
π
Re: Collapse and expand Tree View Widget from code
I just posted my in progress work:
https://github.com/bwmilby/livecode/tre ... -fold-test
https://github.com/bwmilby/livecode/blo ... eeview.lcb
https://github.com/bwmilby/livecode/com ... ed440a9da2
Some pertinent handlers with changes
1393 - pathIsValid (new)
1729 - unfoldPath
1742 - unfoldFullPath (new)
1762 - selectPath
1846 - applyFoldStateKey
1968 - setSelectedElement
The updates allow the widget to unfold the tree to display the selected path. Interactively there is no way to select a path that isn't visible. If setting the selection by code, it is possible. Before this update, the selection just silently failed in that case.
There are also a couple of new handlers in this version that won't get included until later (require the ability to call widget handlers from LCS which isn't available yet).
Once PR 6702 is merged, I'll get an update together with most of the code in this test branch.
https://github.com/livecode/livecode/pull/6702
(An update was merged in the 9.0 branch and some of the changes in develop conflicted. The changes to implement the fold logic further change the same area. Waiting to be sure that I don't create another merge conflict with the update to the widget.)
https://github.com/bwmilby/livecode/tre ... -fold-test
https://github.com/bwmilby/livecode/blo ... eeview.lcb
https://github.com/bwmilby/livecode/com ... ed440a9da2
Some pertinent handlers with changes
1393 - pathIsValid (new)
1729 - unfoldPath
1742 - unfoldFullPath (new)
1762 - selectPath
1846 - applyFoldStateKey
1968 - setSelectedElement
The updates allow the widget to unfold the tree to display the selected path. Interactively there is no way to select a path that isn't visible. If setting the selection by code, it is possible. Before this update, the selection just silently failed in that case.
There are also a couple of new handlers in this version that won't get included until later (require the ability to call widget handlers from LCS which isn't available yet).
Once PR 6702 is merged, I'll get an update together with most of the code in this test branch.
https://github.com/livecode/livecode/pull/6702
(An update was merged in the 9.0 branch and some of the changes in develop conflicted. The changes to implement the fold logic further change the same area. Waiting to be sure that I don't create another merge conflict with the update to the widget.)
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- VIP Livecode Opensource Backer
- Posts: 261
- Joined: Sat Aug 16, 2008 9:48 am
- Location: Stockholm, Sweden
- Contact:
Re: Collapse and expand Tree View Widget from code
Ah, I just ran into this inability of the tree widget. Great to go to the forum for help and see a solution may just be on its way!
Just to check: In my case, I have two tree widgets side by side (with same array structure), and when I fold/unfold in one, I want the other to do the same. Will the improvement described above allow this to be coded?
Just to check: In my case, I have two tree widgets side by side (with same array structure), and when I fold/unfold in one, I want the other to do the same. Will the improvement described above allow this to be coded?
Re: Collapse and expand Tree View Widget from code
PR submitted:
https://github.com/livecode/livecode/pull/6738
@SWEdeAndy
This update doesn't allow to keep two widgets completely in sync automatically. You could always take a selection from one widget and then select in the other widget. This would only do the unfold part. There is another PR required to allow calling handlers inside the LCB code directly.
https://github.com/livecode/livecode/pull/6738
@SWEdeAndy
This update doesn't allow to keep two widgets completely in sync automatically. You could always take a selection from one widget and then select in the other widget. This would only do the unfold part. There is another PR required to allow calling handlers inside the LCB code directly.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Posts: 40
- Joined: Thu May 17, 2018 7:32 pm
- Location: Florida, USA
Re: Collapse and expand Tree View Widget from code
Hello,
I am wondering if there is any further activity on this issue. Specifically, I need to:
1. get a message when the user collapses/expands a fold
2. be able to expand/collapse a fold from code.
thanks,
Mark
I am wondering if there is any further activity on this issue. Specifically, I need to:
1. get a message when the user collapses/expands a fold
2. be able to expand/collapse a fold from code.
thanks,
Mark
Re: Collapse and expand Tree View Widget from code
This has been merged into the develop branch band will appear in the first release in the 9.1 line. You can download the LCB file and compile it now though. You will need to hack your install slightly to replace the widget. The advantage of doing that is that your stacks will work with the release copy once it comes out. If you want further help in how to do this, let me know.
#2 is addressed in the merged code. #1 is not but would be easy to add.
#2 is addressed in the merged code. #1 is not but would be easy to add.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Posts: 40
- Joined: Thu May 17, 2018 7:32 pm
- Location: Florida, USA
Re: Collapse and expand Tree View Widget from code
Thanks for the update. I'll check it out. And thank you for the widget!
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Collapse and expand Tree View Widget from code
Just a small addition to this thread.
Following code will collaps the Tree Widget (LC 9.5)
However I could not find a command to Expand the whole tree
does the same as
Regards,
Paul
Following code will collaps the Tree Widget (LC 9.5)
Code: Select all
on mouseUp
set the FoldState of widget "ArrayView" to true
end mouseUp
Code: Select all
set the FoldState of widget "ArrayView" to false
Code: Select all
set the FoldState of widget "ArrayView" to true
Regards,
Paul