tview icon indicating copy to clipboard operation
tview copied to clipboard

Form is not working while using with pages

Open harisudarsan1 opened this issue 1 year ago • 4 comments

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

harisudarsan1 avatar Jul 30 '23 14:07 harisudarsan1

@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

digitallyserviced avatar Jul 30 '23 19:07 digitallyserviced

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

harisudarsan1 avatar Jul 31 '23 15:07 harisudarsan1

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?

rivo avatar Jul 31 '23 17:07 rivo

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.

digitallyserviced avatar Aug 04 '23 18:08 digitallyserviced

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.

rivo avatar Apr 04 '24 16:04 rivo