[GH-ISSUE #865] Form is not working while using with pages #628

Closed
opened 2026-03-04 01:06:36 +03:00 by kerem · 3 comments
Owner

Originally created by @harisudarsan1 on GitHub (Jul 30, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/865

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:

Screenshot from 2023-07-30 19-47-19

Originally created by @harisudarsan1 on GitHub (Jul 30, 2023). Original GitHub issue: https://github.com/rivo/tview/issues/865 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. ```golang 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](https://github.com/rivo/tview/assets/97289088/14e2c318-c6d6-4c38-8fd3-c33070b7c9e2) But it is working when I use it alone ```golang 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: ![Screenshot from 2023-07-30 19-47-19](https://github.com/rivo/tview/assets/97289088/ef6eabc6-73d7-46b9-b9ad-1c51284a8cd8)
kerem closed this issue 2026-03-04 01:06:36 +03:00
Author
Owner

@harisudarsan1 commented on GitHub (Jul 31, 2023):

In that case the default page is Add contact and still it doesn't work.

<!-- gh-comment-id:1658663128 --> @harisudarsan1 commented on GitHub (Jul 31, 2023): > In that case the default page is Add contact and still it doesn't work.
Author
Owner

@rivo commented on GitHub (Jul 31, 2023):

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?

<!-- gh-comment-id:1658842562 --> @rivo commented on GitHub (Jul 31, 2023): > 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?
Author
Owner

@rivo commented on GitHub (Apr 4, 2024):

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.

<!-- gh-comment-id:2037694329 --> @rivo commented on GitHub (Apr 4, 2024): 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.
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#628
No description provided.