[GH-ISSUE #535] How to select items inside a grid container? #388

Closed
opened 2026-03-04 01:04:34 +03:00 by kerem · 3 comments
Owner

Originally created by @manikandanraji on GitHub (Nov 29, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/535

I have this grid, inside this grid each children is a flex widget. How to select these flex items?

rtv

Originally created by @manikandanraji on GitHub (Nov 29, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/535 I have this grid, inside this grid each children is a flex widget. How to select these flex items? ![rtv](https://user-images.githubusercontent.com/34580944/100533101-a434c580-3226-11eb-9458-685b44833bbf.png)
kerem closed this issue 2026-03-04 01:04:34 +03:00
Author
Owner

@rivo commented on GitHub (Dec 4, 2020):

What do you mean by "select"? Do you want to set the focus to a specific flex item? In your code? Or by the user (and if so, with the keyboard or with the mouse)?

I'm not sure I understand your request.

<!-- gh-comment-id:738846052 --> @rivo commented on GitHub (Dec 4, 2020): What do you mean by "select"? Do you want to set the focus to a specific flex item? In your code? Or by the user (and if so, with the keyboard or with the mouse)? I'm not sure I understand your request.
Author
Owner

@manikandanraji commented on GitHub (Dec 4, 2020):

Yep, I want the user to set the focus to a flex item. For example, by default the first flex item will be focussed, if the user presses 'J' set the focus to the next flex item

Similar to how rtv (reddit terminal viewer) does:
output

<!-- gh-comment-id:738922219 --> @manikandanraji commented on GitHub (Dec 4, 2020): Yep, I want the user to set the focus to a flex item. For example, by default the first flex item will be focussed, if the user presses 'J' set the focus to the next flex item Similar to how rtv (reddit terminal viewer) does: ![output](https://user-images.githubusercontent.com/34580944/101196317-964bce00-3686-11eb-8d4d-19867100a367.gif)
Author
Owner

@tslocum commented on GitHub (Dec 4, 2020):

Container widgets such as Flex and Grid pass focus to the first contained widget with the focus property set. When multiple widgets have focus set, only the first receives focus. To switch focus you must manage the focus state of the application. You can do this by capturing user input via SetInputCapture and listening for Tab and Shift+Tab key events. I created FocusManager (code) to make this process less cumbersome.

<!-- gh-comment-id:738972447 --> @tslocum commented on GitHub (Dec 4, 2020): Container widgets such as Flex and Grid pass focus to the first contained widget with the focus property set. When multiple widgets have focus set, only the first receives focus. To switch focus you must manage the focus state of the application. You can do this by capturing user input via SetInputCapture and listening for Tab and Shift+Tab key events. I created [FocusManager](https://docs.rocketnine.space/gitlab.com/tslocum/cview/#FocusManager) ([code](https://gitlab.com/tslocum/cview/-/blob/master/focus.go)) to make this process less cumbersome.
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#388
No description provided.