This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/examples/button/main.go

32 lines
828 B
Go
Raw Normal View History

2023-01-08 23:03:19 -07:00
package main
import "git.tebibyte.media/sashakoshka/tomo"
2023-03-30 21:19:04 -06:00
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
2023-03-08 18:41:48 -07:00
import "git.tebibyte.media/sashakoshka/ezprof/ez"
2023-01-08 23:03:19 -07:00
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("example button")
2023-03-30 21:19:04 -06:00
button := elements.NewButton("hello tomo!")
2023-01-08 23:03:19 -07:00
button.OnClick (func () {
// when we set the button's text to something longer, the window
// will automatically resize to accomodate it.
button.SetText("you clicked me.\nwow, there are two lines!")
button.OnClick (func () {
button.SetText (
"stop clicking me you idiot!\n" +
"you've already seen it all!")
button.OnClick(tomo.Stop)
})
})
window.Adopt(button)
window.OnClose(tomo.Stop)
window.Show()
2023-03-08 18:41:48 -07:00
ez.Prof()
2023-01-08 23:03:19 -07:00
}