[GH-ISSUE #432] Next node TreeView #313

Closed
opened 2026-03-04 01:03:52 +03:00 by kerem · 5 comments
Owner

Originally created by @xidod on GitHub (Apr 18, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/432

Hello, I'm missing something or is not possible from code go to the next or previous node in the TreeView?
I mean the same thing that arrow up and arrow down do.
For example, if I want every 5 seconds go to the next node from selected node, how I can do this?
We have GetRowCount() and GetScrollOffset but not the list of the nodes.

Originally created by @xidod on GitHub (Apr 18, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/432 Hello, I'm missing something or is not possible from code go to the next or previous node in the TreeView? I mean the same thing that arrow up and arrow down do. For example, if I want every 5 seconds go to the next node from selected node, how I can do this? We have [GetRowCount()](https://pkg.go.dev/github.com/rivo/tview?tab=doc#TreeView.GetRowCountl) and [GetScrollOffset](https://pkg.go.dev/github.com/rivo/tview?tab=doc#TreeView.GetScrollOffset) but not the list of the nodes.
kerem closed this issue 2026-03-04 01:03:52 +03:00
Author
Owner

@tslocum commented on GitHub (May 2, 2020):

This is implemented in #437

<!-- gh-comment-id:622979520 --> @tslocum commented on GitHub (May 2, 2020): This is implemented in #437
Author
Owner

@rivo commented on GitHub (May 7, 2020):

@xidod TreeView is not a linear structure and while it internally (and temporarily) keeps a slice of visible nodes, this is not exposed to avoid users tampering with it. (And because it's temporary, there cannot be any guarantees for that slice.) Have you tried sending a key event to the tree view?

treeView.InputHandler()(tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone))

If this happens in a goroutine, you should use Application.QueueUpdateDraw() (see the Wiki for details).

I haven't tried this myself so it would be good to get some feedback from you. If this doesn't help, I may have to add the corresponding functions.

<!-- gh-comment-id:625413215 --> @rivo commented on GitHub (May 7, 2020): @xidod `TreeView` is not a linear structure and while it internally (and temporarily) keeps a slice of visible nodes, this is not exposed to avoid users tampering with it. (And because it's temporary, there cannot be any guarantees for that slice.) Have you tried sending a key event to the tree view? ```go treeView.InputHandler()(tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone)) ``` If this happens in a goroutine, you should use `Application.QueueUpdateDraw()` (see the [Wiki](https://github.com/rivo/tview/wiki/Concurrency) for details). I haven't tried this myself so it would be good to get some feedback from you. If this doesn't help, I may have to add the corresponding functions.
Author
Owner

@xidod commented on GitHub (May 7, 2020):

@rivo sure, i will try this and i give you a feedback asap

<!-- gh-comment-id:625457623 --> @xidod commented on GitHub (May 7, 2020): @rivo sure, i will try this and i give you a feedback asap
Author
Owner

@xidod commented on GitHub (May 8, 2020):

yes, i can go to the next node and previous node with tcell.NewEventKey(tcell.KeyDown,0,tcell.ModeNone) and tcell.NewEventKey(tcell.KeyUp,0,tcell.ModeNone)
a little tricky but it works.

<!-- gh-comment-id:626032455 --> @xidod commented on GitHub (May 8, 2020): yes, i can go to the next node and previous node with ```tcell.NewEventKey(tcell.KeyDown,0,tcell.ModeNone)``` and ```tcell.NewEventKey(tcell.KeyUp,0,tcell.ModeNone)``` a little tricky but it works.
Author
Owner

@rivo commented on GitHub (Dec 17, 2022):

There is now a function TreeView.Move() that does this.

<!-- gh-comment-id:1356268336 --> @rivo commented on GitHub (Dec 17, 2022): There is now a function `TreeView.Move()` that does this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#313
No description provided.