Improved the example window program that was just merged.

This commit is contained in:
Pietro Gagliardi 2014-11-26 22:09:56 -05:00
parent 07b68e6236
commit dbeb1e8004
1 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,8 @@ import (
)
func main() {
// This runs the code that displays our GUI.
// All code that interfaces with package ui (except event handlers) must be run from within a ui.Do() call.
go ui.Do(gui)
err := ui.Go()
@ -16,16 +17,21 @@ func main() {
}
func gui() {
// Here we create a new space
// All windows must have a control inside.
// ui.Space() creates a control that is just a blank space for us to use.
newControl := ui.Space()
// Then we create a window
// Then we create a window.
w := ui.NewWindow("Window", 280, 350, newControl)
// We tell package ui to destroy our window and shut down cleanly when the user closes the window by clicking the X button in the titlebar.
w.OnClosing(func() bool {
// This informs package ui to shut down cleanly when it can.
ui.Stop()
// And this informs package ui that we want to hide AND destroy the window.
return true
})
// And finally, we need to show the window.
w.Show()
}