From dbeb1e8004e7b0f773dd4aa2d761a6e9a147a8e2 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 26 Nov 2014 22:09:56 -0500 Subject: [PATCH] Improved the example window program that was just merged. --- examples/basicwindow/basicwindow.go | 14 ++++++++++---- 1 file 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() }