mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #412] TreeView.ExpandAll()/SetExpanded not working as expected #303
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#303
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @karlredman on GitHub (Feb 26, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/412
Hi Great work! Thanks you. I'm having an issue whereby I think I'm missing something or that I would like clarification about if possible please.
Description:
What is hapening:
ExpandAll()function only works on nodes that have been manually opened Previously.Expand()doesn't seem to work at all (except for the root node)SetExpanded()only seems to work on root nodeColapseAll()andCollapse()work as expected.Walk()withnode.SetExpanded(true) doesn't do anythingWhat is expected:
ExpandAllshould expand at least the 1st level of directories under the root nodeCode:
Sorry this is kind of a long example. Note that once the state changes on the tree, subsequent behavior of the tree changes -so restarting the application is probably necessary in order to see if/that things are working as expected/unexpectedly. I added kb input so you can fiddle with the behaviors a little easier.
@karlredman commented on GitHub (Feb 26, 2020):
After digging around for a while I think I've narrowed it down to 1 of 3 options:
KeyEnterevent to the tree node after aSetCurrentNode()callSetCurretNode()that will trigger a "changed" callbacktreeview.goand customize as needed (obviously least desirable)I'm not sure what the best option is... Option 2 seems like the best one relative to the 'most control' vs 'least intrusive' trade off.
I can submit a PR if you'd like me to demonstrate a public method that triggers the "changed" callback. I'm reluctant to code it if this kind of thing wouldn't be considered good for the library.
@karlredman commented on GitHub (Mar 2, 2020):
I am closing this ticket with an explanation.
As it turns out I was being silly about the expansion problem. I must have been tired. So, if anyone else thinks they are having this issue keep in mind that the original code doesn't walk the entire tree to add the nodes outright. The fix would be to move the
addvariable to a plain old recursive function that would resemble something like the following. ...@mih-kopylov commented on GitHub (Jan 6, 2023):
@karlredman
As for
When changing current selected node manually, sometimes it's essential to trigger a "changed" and a "selected" callback so that the relevant state updates according to the new current node.
Is there a way to do that?
@quantonganh commented on GitHub (Dec 20, 2024):
@mih-kopylov Could you please try something like this?