[GH-ISSUE #89] Still show last page after Page.SwitchToPage #67

Closed
opened 2026-03-04 01:01:38 +03:00 by kerem · 1 comment
Owner

Originally created by @soyking on GitHub (Mar 29, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/89

I wrote a demo with Page:

package main

import (
	"github.com/rivo/tview"
)

func page1(pages *tview.Pages) tview.Primitive {
	return tview.NewModal().
		SetText("page1").
		AddButtons([]string{"Yes", "No"}).
		SetDoneFunc(func(buttonIndex int, buttonLabel string) {
			pages.SwitchToPage("page2")
		})
}

func page2(pages *tview.Pages) tview.Primitive {
	return tview.NewButton("page2")
}

func main() {
	app := tview.NewApplication()
	pages := tview.NewPages()
	pages.AddPage("page1", page1(pages), false, true)
	pages.AddPage("page2", page2(pages), false, false)

	if err := app.SetRoot(pages, true).Run(); err != nil {
		panic(err)
	}
}

After running, and input enter:

image

What can I do to make it only show page2 ? Thanks.

Originally created by @soyking on GitHub (Mar 29, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/89 I wrote a demo with Page: ``` package main import ( "github.com/rivo/tview" ) func page1(pages *tview.Pages) tview.Primitive { return tview.NewModal(). SetText("page1"). AddButtons([]string{"Yes", "No"}). SetDoneFunc(func(buttonIndex int, buttonLabel string) { pages.SwitchToPage("page2") }) } func page2(pages *tview.Pages) tview.Primitive { return tview.NewButton("page2") } func main() { app := tview.NewApplication() pages := tview.NewPages() pages.AddPage("page1", page1(pages), false, true) pages.AddPage("page2", page2(pages), false, false) if err := app.SetRoot(pages, true).Run(); err != nil { panic(err) } } ``` After running, and input enter: ![image](https://user-images.githubusercontent.com/3882738/38072176-c9589b00-3357-11e8-855f-d2a143e6e0dc.png) What can I do to make it only show page2 ? Thanks.
kerem closed this issue 2026-03-04 01:01:38 +03:00
Author
Owner

@rivo commented on GitHub (Mar 29, 2018):

Right. I just fixed this. It's odd that this hadn't been detected before.

<!-- gh-comment-id:377292975 --> @rivo commented on GitHub (Mar 29, 2018): Right. I just fixed this. It's odd that this hadn't been detected before.
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#67
No description provided.