2018-01-03 20:13:32 +00:00
|
|
|
// Demo code for the InputField primitive.
|
2017-12-27 15:05:00 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-10-18 12:15:57 +00:00
|
|
|
"github.com/gdamore/tcell/v2"
|
2017-12-27 15:05:00 +00:00
|
|
|
"github.com/rivo/tview"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := tview.NewApplication()
|
|
|
|
inputField := tview.NewInputField().
|
|
|
|
SetLabel("Enter a number: ").
|
2018-03-15 16:14:14 +00:00
|
|
|
SetPlaceholder("E.g. 1234").
|
2018-01-17 20:17:59 +00:00
|
|
|
SetFieldWidth(10).
|
2017-12-27 15:05:00 +00:00
|
|
|
SetAcceptanceFunc(tview.InputFieldInteger).
|
|
|
|
SetDoneFunc(func(key tcell.Key) {
|
|
|
|
app.Stop()
|
|
|
|
})
|
2020-03-27 17:41:44 +00:00
|
|
|
if err := app.SetRoot(inputField, true).EnableMouse(true).Run(); err != nil {
|
2017-12-27 15:05:00 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|