[GH-ISSUE #530] General Questions about TView #386

Closed
opened 2026-03-04 01:04:33 +03:00 by kerem · 2 comments
Owner

Originally created by @syacko-sote on GitHub (Nov 18, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/530

Hello,

Thank you for addressing these questions:

  1. Is it possible to have two or more tview.List on the screen at the same time. If so, how do you switch focus from one tview.List to another when using the arrow keys to navigate. An example might be a list of configuration options that have shortcuts, which when selected, a model form appears for input. The second tview.List has a list of DB tables that display info when selected.

  2. Is there a way to set the min and max size of the screen for the Flex option?

  3. Is it possible to have a Flex object inside another Flex object?

  4. Is it possible to set the width / height of the screen when Flex is not used?

  5. Can a tview.Table be added to a tview.TextView?

  6. I have added a tview.Table to a tview.NewFlex(). Is there a way to reference the cells in the table, so they can be updated?

Thank you for your patience and again, I really like the tview package.

Originally created by @syacko-sote on GitHub (Nov 18, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/530 Hello, Thank you for addressing these questions: 1. Is it possible to have two or more tview.List on the screen at the same time. If so, how do you switch focus from one tview.List to another when using the arrow keys to navigate. An example might be a list of configuration options that have shortcuts, which when selected, a model form appears for input. The second tview.List has a list of DB tables that display info when selected. 2. Is there a way to set the min and max size of the screen for the Flex option? 3. Is it possible to have a Flex object inside another Flex object? 4. Is it possible to set the width / height of the screen when Flex is not used? 5. Can a tview.Table be added to a tview.TextView? 6. I have added a tview.Table to a tview.NewFlex(). Is there a way to reference the cells in the table, so they can be updated? Thank you for your patience and again, I really like the tview package.
kerem closed this issue 2026-03-04 01:04:33 +03:00
Author
Owner

@tslocum commented on GitHub (Nov 26, 2020):

Hey @syacko-sote, I am not the maintainer of tview but I am glad to answer your questions.

Is it possible to have two or more tview.List on the screen at the same time. If so, how do you switch focus from one tview.List to another when using the arrow keys to navigate.

Yes, any number of widgets may be displayed on the screen. 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 for 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.

Is there a way to set the min and max size of the screen for the Flex option?

Flex.AddItem takes the argument fixedSize which may be used to set the maximum size of the item on the screen.

Is it possible to have a Flex object inside another Flex object?

Yes, widgets do not have any nesting limitations that I am aware of.

Is it possible to set the width / height of the screen when Flex is not used?

You can set the width and height of a widget in several ways. If it is the only widget on the screen, you could directly set its width and height via SetRect. However the best way, at least in my opinion, is to use a Grid via SetRows and SetColumns, because it can be adapted more easily as the application evolves and more widgets are added.

Can a tview.Table be added to a tview.TextView?

TextView is a text display widget, it does not allow other widgets to be added to it. If you are looking to use multiple TextViews in a tabular fashion, use a Grid. Let me know if you meant something else.

I have added a tview.Table to a tview.NewFlex(). Is there a way to reference the cells in the table, so they can be updated?

Yes, Table.GetCell returns a reference to the a cell in the table, which you can manipulate. Just be sure to call App.Draw after making changes.

<!-- gh-comment-id:734056460 --> @tslocum commented on GitHub (Nov 26, 2020): Hey @syacko-sote, I am not the maintainer of tview but I am glad to answer your questions. > Is it possible to have two or more tview.List on the screen at the same time. If so, how do you switch focus from one tview.List to another when using the arrow keys to navigate. Yes, any number of widgets may be displayed on the screen. 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 for 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. > Is there a way to set the min and max size of the screen for the Flex option? `Flex.AddItem` takes the argument `fixedSize` which may be used to set the maximum size of the item on the screen. > Is it possible to have a Flex object inside another Flex object? Yes, widgets do not have any nesting limitations that I am aware of. > Is it possible to set the width / height of the screen when Flex is not used? You can set the width and height of a widget in several ways. If it is the only widget on the screen, you could directly set its width and height via `SetRect`. However the best way, at least in my opinion, is to use a `Grid` via `SetRows` and `SetColumns`, because it can be adapted more easily as the application evolves and more widgets are added. > Can a tview.Table be added to a tview.TextView? `TextView` is a text display widget, it does not allow other widgets to be added to it. If you are looking to use multiple `TextView`s in a tabular fashion, use a `Grid`. Let me know if you meant something else. > I have added a tview.Table to a tview.NewFlex(). Is there a way to reference the cells in the table, so they can be updated? Yes, `Table.GetCell` returns a reference to the a cell in the table, which you can manipulate. Just be sure to call `App.Draw` after making changes.
Author
Owner

@syacko-sote commented on GitHub (Dec 1, 2020):

Thank you so much for your feedback. Hopefully, this will help others new to tview.

<!-- gh-comment-id:736276254 --> @syacko-sote commented on GitHub (Dec 1, 2020): Thank you so much for your feedback. Hopefully, this will help others new to tview.
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#386
No description provided.