diff options
| author | Pietro Gagliardi <[email protected]> | 2014-11-26 22:09:56 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-11-26 22:09:56 -0500 |
| commit | dbeb1e8004e7b0f773dd4aa2d761a6e9a147a8e2 (patch) | |
| tree | 70ebf6f174a152cc6d44b2c1ebb85dacbdd93341 /examples | |
| parent | 07b68e6236bc1e76df0e90b112032ef182babc13 (diff) | |
Improved the example window program that was just merged.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/basicwindow/basicwindow.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/basicwindow/basicwindow.go b/examples/basicwindow/basicwindow.go index 8b3b4a2..c0259f5 100644 --- a/examples/basicwindow/basicwindow.go +++ b/examples/basicwindow/basicwindow.go @@ -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() } |
