Last active
August 22, 2019 22:04
-
-
Save pkramme/704cc6946fb7728faad136814f104d09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/rivo/tview" | |
func main() { | |
app := tview.NewApplication() | |
MainPages := tview.NewPages() | |
QuitDialog := tview.NewModal(). | |
SetText("Do you want to quit the application?"). | |
AddButtons([]string{"Cancel", "Quit"}). | |
SetDoneFunc(func(buttonIndex int, buttonLabel string) { | |
if buttonLabel == "Quit" { | |
app.Stop() | |
} else { | |
MainPages.SwitchToPage("main") | |
} | |
}) | |
MainMenu := tview.NewList().AddItem("Quit", "Press to exit", 'q', func() { | |
MainPages.AddAndSwitchToPage("QuitDialog", QuitDialog, true) | |
}) | |
MainPages.AddPage("main", MainMenu, false, true) | |
if err := app.SetRoot(MainPages, true).Run(); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment