2023-01-17 22:38:58 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
2023-01-17 23:29:59 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
2023-02-01 23:48:16 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
2023-01-17 22:38:58 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
2023-03-15 23:14:39 -06:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-03-16 12:22:56 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
2023-01-17 22:38:58 -07:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
|
|
|
window, _ := tomo.NewWindow(2, 2)
|
2023-01-18 09:56:14 -07:00
|
|
|
window.SetTitle("Enter Details")
|
2023-03-16 12:22:56 -06:00
|
|
|
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
2023-01-17 22:38:58 -07:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-01-18 09:56:14 -07:00
|
|
|
// create inputs
|
2023-02-01 23:48:16 -07:00
|
|
|
firstName := basicElements.NewTextBox("First name", "")
|
|
|
|
lastName := basicElements.NewTextBox("Last name", "")
|
|
|
|
fingerLength := basicElements.NewTextBox("Length of fingers", "")
|
|
|
|
button := basicElements.NewButton("Ok")
|
2023-01-17 23:29:59 -07:00
|
|
|
|
2023-01-18 09:56:14 -07:00
|
|
|
button.SetEnabled(false)
|
2023-01-17 23:29:59 -07:00
|
|
|
button.OnClick (func () {
|
2023-01-18 09:56:14 -07:00
|
|
|
// create a dialog displaying the results
|
2023-01-17 23:29:59 -07:00
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindInfo,
|
|
|
|
"Profile",
|
2023-01-18 09:56:14 -07:00
|
|
|
firstName.Value() + " " + lastName.Value() +
|
|
|
|
"'s fingers\nmeasure in at " + fingerLength.Value() +
|
|
|
|
" feet.")
|
2023-01-17 23:29:59 -07:00
|
|
|
})
|
2023-01-18 09:56:14 -07:00
|
|
|
|
|
|
|
// enable the Ok button if all three inputs have text in them
|
|
|
|
check := func () {
|
|
|
|
button.SetEnabled (
|
|
|
|
firstName.Filled() &&
|
|
|
|
lastName.Filled() &&
|
|
|
|
fingerLength.Filled())
|
|
|
|
}
|
|
|
|
firstName.OnChange(check)
|
|
|
|
lastName.OnChange(check)
|
|
|
|
fingerLength.OnChange(check)
|
|
|
|
|
|
|
|
// add elements to container
|
2023-02-01 23:48:16 -07:00
|
|
|
container.Adopt(basicElements.NewLabel("Choose your words carefully.", false), true)
|
2023-01-17 22:38:58 -07:00
|
|
|
container.Adopt(firstName, false)
|
|
|
|
container.Adopt(lastName, false)
|
|
|
|
container.Adopt(fingerLength, false)
|
2023-02-01 23:48:16 -07:00
|
|
|
container.Adopt(basicElements.NewSpacer(true), false)
|
2023-01-17 22:38:58 -07:00
|
|
|
container.Adopt(button, false)
|
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|