-
-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How do I display form above the grid? #359
Comments
I don't think anything has changed in how package main
import "github.com/rivo/tview"
func main() {
grid := tview.NewGrid()
grid.AddItem(tview.NewBox().SetTitle("Box1").SetBorder(true), 0, 0, 1, 1, 0, 0, false)
grid.AddItem(tview.NewBox().SetTitle("Box2").SetBorder(true), 1, 0, 1, 1, 0, 0, false)
form := tview.NewForm()
form.AddInputField("Input:", "", 20, nil, nil)
form.AddButton("Click me", nil)
form.SetBorder(true)
pages := tview.NewPages()
pages.AddPage("grid", grid, true, true)
pages.AddPage("form", form, false, true)
if err := tview.NewApplication().SetRoot(pages, true).Run(); err != nil {
panic(err)
}
} And what it looks like: I guess the question is, what function are you using to display your form? |
@rivo My sample code is following. package main
import "github.com/rivo/tview"
func main() {
grid := tview.NewGrid()
grid.AddItem(tview.NewBox().SetTitle("Box1").SetBorder(true), 0, 0, 1, 1, 0, 0, false)
grid.AddItem(tview.NewBox().SetTitle("Box2").SetBorder(true), 1, 0, 1, 1, 0, 0, false)
form := tview.NewForm()
form.AddInputField("Input:", "", 20, nil, nil)
form.AddButton("Click me", nil)
form.SetBorder(true)
pages := tview.NewPages()
pages.AddPage("grid", grid, true, true)
pages.AddPage("form", modal(form), true, true).ShowPage("grid")
if err := tview.NewApplication().SetRoot(pages, true).Run(); err != nil {
panic(err)
}
}
func modal(p tview.Primitive) tview.Primitive {
return tview.NewGrid().SetColumns(0, 0, 0).SetRows(0, 0, 0).AddItem(p, 1, 1, 1, 1, 0, 0, true)
} When I use Is there any other way to put primitives such as form in the center of the screen? |
Right. Thanks for this additional info. This one line in the |
@rivo Thanks :) |
Previously, in #264 you could use "pages" to display the form in the grid, but now it seems that you can't.
Is there a way to display the form while displaying the grid?
The text was updated successfully, but these errors were encountered: