mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #823] TreeView SetCurrentNode is not triggering changed callback #599
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#599
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 @jdfa on GitHub (Mar 10, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/823
While it is really good that current behavior is documented in comment, I would like to have get different thing.
I am using
TreeViewand reimplemented navigation for few keys. It is nothing extraordinary: LeftArrow will switch to parent node, RightArrow - to first child with some extra conditions.For that, In
inputCaptureI am callingSetCurrentNodewhich doesn't triggerchangedcallback. I would do that manually, but there is no method to access that callback.@jdfa commented on GitHub (Mar 12, 2023):
@digitallyserviced Thanks, that helped me to find workaround. In my case I just moved my "OnChanged" logic from
TreeView::SetChangedFunctoApplication::SetBeforeDrawFunc.But I am sure that this is not clean solution,
TreeViewapi should handle such scenario.@rivo commented on GitHub (Mar 25, 2023):
@digitallyserviced is right in that the call to the "changed" function is delayed until
Drawis called next time. I would think, though, that if you rebind keys usingSetInputCapture(), this would lead to a call toDrawimmediately afterwards, thus triggering the "changed" callback. Without any more details, though, I can't tell why this isn't happening.@rivo commented on GitHub (Mar 25, 2023):
Actually, looking at this again in some more detail, the way it was implemented, there was indeed no good way to trigger the "changed" callback when calling
SetCurrentNode(). This should be fixed with the latest commit. It will still only be triggered during drawing, but it will be triggered in any case.