[GH-ISSUE #309] Hide/show a widget in a flex layout on demand #234

Closed
opened 2026-03-04 01:03:11 +03:00 by kerem · 4 comments
Owner

Originally created by @lenormf on GitHub (Jun 17, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/309

Hi,

I want to hide/show a TextView widget in a Flex layout on demand, the goal would be to show contextual information depending on the state of the application (e.g. tips, completion candidates).

A proposal based on adding nil objects to the layout has been hinted at in #104, what is the status of that feature?

Thanks!

Originally created by @lenormf on GitHub (Jun 17, 2019). Original GitHub issue: https://github.com/rivo/tview/issues/309 Hi, I want to hide/show a `TextView` widget in a `Flex` layout on demand, the goal would be to show contextual information depending on the state of the application (e.g. tips, completion candidates). A proposal based on adding `nil` objects to the layout has been hinted at in #104, what is the status of that feature? Thanks!
kerem closed this issue 2026-03-04 01:03:11 +03:00
Author
Owner

@rivo commented on GitHub (Jun 18, 2019):

nil objects can be added to Flex, see AddItem():

You can provide a nil value for the primitive. This will still consume screen space but nothing will be drawn.

But I'm not sure that this will help you achieve what you want to do. Do you want the TextView to be temporarily empty or do you want to take it out of the layout completely? There is a RemoveItem() function.

<!-- gh-comment-id:503023276 --> @rivo commented on GitHub (Jun 18, 2019): `nil` objects can be added to `Flex`, see [`AddItem()`](https://godoc.org/github.com/rivo/tview#Flex.AddItem): > You can provide a nil value for the primitive. This will still consume screen space but nothing will be drawn. But I'm not sure that this will help you achieve what you want to do. Do you want the `TextView` to be temporarily empty or do you want to take it out of the layout completely? There is a [`RemoveItem()`](https://godoc.org/github.com/rivo/tview#Flex.RemoveItem) function.
Author
Owner

@lenormf commented on GitHub (Jun 18, 2019):

I want the TextView not to take any screen space unless I'm printing information in it, possibly without having to re-instantiate it every time I need it.

<!-- gh-comment-id:503053080 --> @lenormf commented on GitHub (Jun 18, 2019): I want the `TextView` not to take any screen space unless I'm printing information in it, possibly without having to re-instantiate it every time I need it.
Author
Owner

@rivo commented on GitHub (Jul 10, 2019):

You don't need to re-instantiate it. When you call RemoveItem(), it's just taken out of the Flex layout. You can call AddItem() with the same TextView object again.

<!-- gh-comment-id:510025683 --> @rivo commented on GitHub (Jul 10, 2019): You don't need to re-instantiate it. When you call `RemoveItem()`, it's just taken out of the `Flex` layout. You can call `AddItem()` with the same ` TextView` object again.
Author
Owner

@lenormf commented on GitHub (Jul 10, 2019):

Thanks, I'll play around with that then. Closing, in the meantime.

<!-- gh-comment-id:510114156 --> @lenormf commented on GitHub (Jul 10, 2019): Thanks, I'll play around with that then. Closing, in the meantime.
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#234
No description provided.