mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #283] TreeView scrolling hooks #218
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#218
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 @ollien on GitHub (May 18, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/283
It doesn't appear there's a way to hook into the scrolling of the tree view. I'm trying to make a tree that will load lazily, so it would be really nice if I could hook into the scrolling to detect when I need to load more information. Right now, it looks like I can use
TreeView.GetCurrentNode, but I don't see a mechanism to determine if that node is actually visible on the screen, or how close to the bottom the current node is.In an ideal world, it would be really nice if there could be hooks to catch scrolling events for
TreeView, or at least some way to tell if the user has a current node that is close to the bottom of the screen (and thus necessitating the fetching of new information).@rivo commented on GitHub (Jun 9, 2019):
The latest commit adds two functions
GetScrollOffset()andGetRowCount()to theTreeViewprimitive. This, together withBox.GetInnerRect(), will allow you to determine which part of the tree structure is currently shown. As you'll see in the documentation, the new functions' return values will only be up to date after the tree view has been drawn. I would suggest that you useApplication.SetAfterDrawFunc()to check if there were any changes to these values and then act accordingly.Let me know in case you still have any questions.
@ollien commented on GitHub (Jun 16, 2019):
@rivo I can't make
GetRowCountreturn anything other than 0. Here's a minimal example that reproduces the issue.I suspect the culprit is that
t.nodesis set tonilafter drawinggithub.com/rivo/tview@b62197ade4/treeview.go (L569-L571)Indeed, if I remove this, I get a non-zero result.
I can open a PR with this, but I'm going to do more poking to see if there are any undesirable side-effects of doing so.Check out #308.