diff --git a/elements/basic/textbox.go b/elements/basic/textbox.go index 90417c7..2d9ba2d 100644 --- a/elements/basic/textbox.go +++ b/elements/basic/textbox.go @@ -183,6 +183,10 @@ func (element *TextBox) SetText (text string) { } } +func (element *TextBox) Value () (value string) { + return string(element.text) +} + func (element *TextBox) draw () { bounds := element.core.Bounds() diff --git a/examples/input/main.go b/examples/input/main.go index 3ae3731..e0530c6 100644 --- a/examples/input/main.go +++ b/examples/input/main.go @@ -1,6 +1,7 @@ package main import "git.tebibyte.media/sashakoshka/tomo" +import "git.tebibyte.media/sashakoshka/tomo/popups" import "git.tebibyte.media/sashakoshka/tomo/layouts" import "git.tebibyte.media/sashakoshka/tomo/elements/basic" import _ "git.tebibyte.media/sashakoshka/tomo/backends/x" @@ -17,9 +18,17 @@ func run () { firstName := basic.NewTextBox("First name", "") lastName := basic.NewTextBox("Last name", "") - lastName.SetEnabled(false) fingerLength := basic.NewTextBox("Length of fingers", "") button := basic.NewButton("Ok") + + lastName.SetEnabled(false) + button.OnClick (func () { + popups.NewDialog ( + popups.DialogKindInfo, + "Profile", + firstName.Value() + " [REDACTED]'s fingers\n" + + "measure in at " + fingerLength.Value() + " feet.") + }) container.Adopt(basic.NewLabel("Choose your words carefully.", false), true) container.Adopt(firstName, false)