| 1 | package mainscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/presentation`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/gdamore/tcell/v2scip-go gomod github.com/gdamore/tcell/v2 v2.7.4 `github.com/gdamore/tcell/v2`/" |
| 5 | "github.com/darkhz/tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/" |
| 6 | ) |
| 7 | |
| 8 | const inputFieldscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/presentation`/inputField. = `[green]package[white] main |
| 9 | |
| 10 | [green]import[white] ( |
| 11 | [red]"strconv"[white] |
| 12 | |
| 13 | [red]"github.com/gdamore/tcell/v2"[white] |
| 14 | [red]"github.com/darkhz/tview"[white] |
| 15 | ) |
| 16 | |
| 17 | [green]func[white] [yellow]main[white]() { |
| 18 | input := tview.[yellow]NewInputField[white](). |
| 19 | [yellow]SetLabel[white]([red]"Enter a number: "[white]). |
| 20 | [yellow]SetAcceptanceFunc[white]( |
| 21 | tview.InputFieldInteger, |
| 22 | ).[yellow]SetDoneFunc[white]([yellow]func[white](key tcell.Key) { |
| 23 | text := input.[yellow]GetText[white]() |
| 24 | n, _ := strconv.[yellow]Atoi[white](text) |
| 25 | [blue]// We have a number.[white] |
| 26 | }) |
| 27 | tview.[yellow]NewApplication[white](). |
| 28 | [yellow]SetRoot[white](input, true). |
| 29 | [yellow]Run[white]() |
| 30 | }` |
| 31 | |
| 32 | // InputField demonstrates the InputField. |
| 33 | func InputFieldscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/presentation`/InputField().(nextSlide func()) (title string, content tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.Primitivescip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/Primitive#) { |
| 34 | input := tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.NewInputFieldscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/NewInputField().(). |
| 35 | SetLabelscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/InputField#SetLabel().("Enter a number: "). |
| 36 | SetAcceptanceFuncscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/InputField#SetAcceptanceFunc().(tviewscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/.InputFieldIntegerscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/InputFieldInteger.).SetDoneFuncscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview`/InputField#SetDoneFunc().(func(key tcellscip-go gomod github.com/gdamore/tcell/v2 v2.7.4 `github.com/gdamore/tcell/v2`/.Keyscip-go gomod github.com/gdamore/tcell/v2 v2.7.4 `github.com/gdamore/tcell/v2`/Key#) { |
| 37 | nextSlide() |
| 38 | }) |
| 39 | return "Input", Codescip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/presentation`/Code().(input, 30, 1, inputFieldscip-go gomod github.com/darkhz/tview . `github.com/darkhz/tview/demos/presentation`/inputField.) |
| 40 | } |