[GH-ISSUE #829] Is there a simple way to switch whether the widget in flex is fullscreen in flex? #602

Open
opened 2026-03-04 01:06:22 +03:00 by kerem · 2 comments
Owner

Originally created by @sunyuechi on GitHub (Mar 23, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/829

I didn't find an easy way, so when I have two widgets, I do this, but if I add more widgets, the judgment seems to be troublesome.

boxRight := tview.NewFlex().SetDirection(tview.FlexRow).AddItem(conversationView, 0, 3, false).AddItem(inputField, 0, 1, true)

_, _, _, fullheight := boxRight.GetInnerRect()

for i := 0; i < boxRight.GetItemCount(); i++ {
		item := boxRight.GetItem(i)
		_, _, _, height := item.GetRect()
		if item.HasFocus() {
			if height < fullheight-2 {
				boxRight.ResizeItem(item, 0, 999)
			} else {
				if item == inputField {
					boxRight.ResizeItem(item, 0, 1)
				}
				if item == conversationView {
					boxRight.ResizeItem(item, 0, 3)
				}
			}
		}
}

Another related question is I want to get Proportion, but didn't find a way..

type flexItem struct {
	Item       Primitive // The item to be positioned. May be nil for an empty item.
	FixedSize  int       // The item's fixed size which may not be changed, 0 if it has no fixed size.
	Proportion int       // The item's proportion.
	Focus      bool      // Whether or not this item attracts the layout's focus.
}
Originally created by @sunyuechi on GitHub (Mar 23, 2023). Original GitHub issue: https://github.com/rivo/tview/issues/829 I didn't find an easy way, so when I have two widgets, I do this, but if I add more widgets, the judgment seems to be troublesome. ```golang boxRight := tview.NewFlex().SetDirection(tview.FlexRow).AddItem(conversationView, 0, 3, false).AddItem(inputField, 0, 1, true) _, _, _, fullheight := boxRight.GetInnerRect() for i := 0; i < boxRight.GetItemCount(); i++ { item := boxRight.GetItem(i) _, _, _, height := item.GetRect() if item.HasFocus() { if height < fullheight-2 { boxRight.ResizeItem(item, 0, 999) } else { if item == inputField { boxRight.ResizeItem(item, 0, 1) } if item == conversationView { boxRight.ResizeItem(item, 0, 3) } } } } ``` Another related question is I want to get Proportion, but didn't find a way.. ``` type flexItem struct { Item Primitive // The item to be positioned. May be nil for an empty item. FixedSize int // The item's fixed size which may not be changed, 0 if it has no fixed size. Proportion int // The item's proportion. Focus bool // Whether or not this item attracts the layout's focus. } ```
Author
Owner

@rivo commented on GitHub (Mar 25, 2023):

To be honest, I don't really understand what you're trying to achieve. Maybe you'll want to provide a graphic which illustrates the layout you're trying to create, along with more detailed explanations? From the code you provided, I don't know what the goal is.

Given the title of this issue, I can say that no, there is no simple way in Flex to switch to full-screen. I would suggest that you use a Pages element which contains the element to be "magnified" and temporarily put it in the front.

<!-- gh-comment-id:1483928956 --> @rivo commented on GitHub (Mar 25, 2023): To be honest, I don't really understand what you're trying to achieve. Maybe you'll want to provide a graphic which illustrates the layout you're trying to create, along with more detailed explanations? From the code you provided, I don't know what the goal is. Given the title of this issue, I can say that no, there is no simple way in `Flex` to switch to full-screen. I would suggest that you use a `Pages` element which contains the element to be "magnified" and temporarily put it in the front.
Author
Owner

@sunyuechi commented on GitHub (Mar 26, 2023):

@rivo Sorry for not expressing clearly, what I think is, when I create a flex layout, add some items into it, and then focus on any of the items, can this part be simply full screen

sideBar      := tview.NewList()
mainBox    := tview.NewFlex().SetDirection(tview.FlexRow).AddItem(conversation, 0, 3, false).AddItem(inputField, 0, 1, true)
box := tview.NewFlex().
		AddItem(mainBox, 0, 4, true).
		AddItem(sideBar, 0, 1, false)

for example, when I focus sidebar or conversation or inputField , I want to toggle whether it is full screen or not

<!-- gh-comment-id:1483970062 --> @sunyuechi commented on GitHub (Mar 26, 2023): @rivo Sorry for not expressing clearly, what I think is, when I create a flex layout, add some items into it, and then focus on any of the items, can this part be simply full screen ``` sideBar := tview.NewList() mainBox := tview.NewFlex().SetDirection(tview.FlexRow).AddItem(conversation, 0, 3, false).AddItem(inputField, 0, 1, true) box := tview.NewFlex(). AddItem(mainBox, 0, 4, true). AddItem(sideBar, 0, 1, false) ``` for example, when I focus sidebar or conversation or inputField , I want to toggle whether it is full screen or not
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#602
No description provided.