...

Source file src/github.com/rivo/tview/demos/modal/main.go

Documentation: github.com/rivo/tview/demos/modal

     1  // Demo code for the Modal primitive.
     2  package main
     3  
     4  import (
     5  	"github.com/rivo/tview"
     6  )
     7  
     8  func main() {
     9  	app := tview.NewApplication()
    10  	modal := tview.NewModal().
    11  		SetText("Do you want to quit the application?").
    12  		AddButtons([]string{"Quit", "Cancel"}).
    13  		SetDoneFunc(func(buttonIndex int, buttonLabel string) {
    14  			if buttonLabel == "Quit" {
    15  				app.Stop()
    16  			}
    17  		})
    18  	if err := app.SetRoot(modal, false).EnableMouse(true).Run(); err != nil {
    19  		panic(err)
    20  	}
    21  }
    22  

View as plain text