tview
tview copied to clipboard
Form is not working while using with pages
OS : Popos 22.04 Description: Form is not working when I use it as pages but it is working when used it alone. I will attach the code and screenshots below.
var form = tview.NewForm().AddButton("Save", func() {
})
var pages = tview.NewPages().
AddPage("Menu", text, true, true).
AddPage("Add Contact", form, true, false)
func main() {
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 113 {
app.Stop()
} else if event.Rune() == 97 {
addContactForm()
pages.SwitchToPage("Add contact")
}
return event
})
if err := app.SetRoot(pages, true).EnableMouse(true).Run(); err != nil {
panic(err)
}
}
Result of this code Screencast from 07-30-2023 07:43:56 PM.webm
But it is working when I use it alone
var form = tview.NewForm().AddButton("Save", func() {
})
func main() {
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 113 {
app.Stop()
} else if event.Rune() == 97 {
// addContactForm()
// pages.SwitchToPage("Add contact")
}
return event
})
if err := app.SetRoot(form, true).EnableMouse(true).Run(); err != nil {
panic(err)
}
}
result:
@HARI-124
What happens if you mark the add contact
page as visible? also use the bring to front method as well.
btw your screen recording didnt show anything.. just nvim and toggle term.. its 1s long
var pages = tview.NewPages().
AddPage("Menu", text, true, true).
AddPage("Add Contact", form, true, true) // last param true
In that case the default page is Add contact and still it doesn't work.
Form is not working
I'm not sure what you mean by this but your code works for me if you make the form visible like @digitallyserviced says. The form is visible like in your static screenshot. (Your video doesn't show anything.)
In that case the default page is Add contact and still it doesn't work.
Please explain what you mean by "it doesn't work". What are you expecting to happen?
In that case the default page is Add contact and still it doesn't work.
@HARI-124 can you rephrase your issue and also if you can update the video/GIF/screenshots that you say point or show the issue, as the webm you provided doesn't show anything useful.
Looks like there is no interest in following up on this anymore. Feel free to open a new issue if this topic is still relevant.