Documented that event channels can be assigned to each other to collapse events.
This commit is contained in:
parent
0a54daa7b1
commit
9e185d815e
|
@ -10,6 +10,7 @@ import (
|
||||||
type Button struct {
|
type Button struct {
|
||||||
// Clicked gets a message when the button is clicked.
|
// Clicked gets a message when the button is clicked.
|
||||||
// You cannot change it once the Window containing the Button has been opened.
|
// You cannot change it once the Window containing the Button has been opened.
|
||||||
|
// If you do not respond to this signal, nothing will happen.
|
||||||
Clicked chan struct{}
|
Clicked chan struct{}
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
4
doc.go
4
doc.go
|
@ -7,9 +7,9 @@ To use the library, place your main program code in another function and call Go
|
||||||
|
|
||||||
Building GUIs is as simple as creating a Window, populating it with Controls, and then calling Open() on the Window. A Window only has one Control: you pack multiple Controls into a Window by arranging them in layouts (Layouts are also Controls). There are presently two Layouts, Stack and Grid, each with different semantics on sizing and placement. See their documentation.
|
Building GUIs is as simple as creating a Window, populating it with Controls, and then calling Open() on the Window. A Window only has one Control: you pack multiple Controls into a Window by arranging them in layouts (Layouts are also Controls). There are presently two Layouts, Stack and Grid, each with different semantics on sizing and placement. See their documentation.
|
||||||
|
|
||||||
Once a Window is open, you cannot make layout changes.
|
Once a Window is open, you cannot make layout or event channel changes.
|
||||||
|
|
||||||
Once your Window is open, you can begin to handle events. Handling events is simple: because all events are channels exposed as exported members of the Window and Control types, simply select on them.
|
Once your Window is open, you can begin to handle events. Handling events is simple: because all events are channels exposed as exported members of the Window and Control types, simply select on them. Event channels are initialized by default. However, before you Open a Window, you can freely reassign event channels, such that multiple events trigger the same channel, making event logic more compact. You may also choose not to handle events; events are sent asynchronously so the GUI loop is not initerrupted.
|
||||||
|
|
||||||
Here is a simple, complete program that asks the user for their name and greets them after clicking a button.
|
Here is a simple, complete program that asks the user for their name and greets them after clicking a button.
|
||||||
package main
|
package main
|
||||||
|
|
|
@ -25,6 +25,7 @@ general list:
|
||||||
- when adding menus:
|
- when adding menus:
|
||||||
- provide automated About, Preferneces, and Quit that place these in the correct location
|
- provide automated About, Preferneces, and Quit that place these in the correct location
|
||||||
- Quit should pulse AppQuit
|
- Quit should pulse AppQuit
|
||||||
|
- will probably want to bring back Event() as NewEvent() should that facility be necesary for menus, etc.
|
||||||
|
|
||||||
problem points:
|
problem points:
|
||||||
- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one (which would be desirable, maybe (would violate Windows HIG?))
|
- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one (which would be desirable, maybe (would violate Windows HIG?))
|
||||||
|
|
2
init.go
2
init.go
|
@ -17,7 +17,7 @@ func Go(main func()) error {
|
||||||
|
|
||||||
// AppQuit is pulsed when the user decides to quit the program if their operating system provides a facility for quitting an entire application, rather than merely close all windows (for instance, Mac OS X via the Dock icon).
|
// AppQuit is pulsed when the user decides to quit the program if their operating system provides a facility for quitting an entire application, rather than merely close all windows (for instance, Mac OS X via the Dock icon).
|
||||||
// You should assign one of your Windows's Closing to this variable so the user choosing to quit the application is treated the same as closing that window.
|
// You should assign one of your Windows's Closing to this variable so the user choosing to quit the application is treated the same as closing that window.
|
||||||
// If you do not respond to this signal, nothing will happen.
|
// If you do not respond to this signal, nothing will happen; regardless of whether or not you respond to this signal, the application will not quit.
|
||||||
// Do not merely check this channel alone; it is not guaranteed to be pulsed on all systems or in all conditions.
|
// Do not merely check this channel alone; it is not guaranteed to be pulsed on all systems or in all conditions.
|
||||||
var AppQuit chan struct{}
|
var AppQuit chan struct{}
|
||||||
|
|
||||||
|
|
2
todo.md
2
todo.md
|
@ -1,8 +1,6 @@
|
||||||
so I don't forget:
|
so I don't forget:
|
||||||
- should Labels be selectable?
|
- should Labels be selectable?
|
||||||
- Message boxes should not show secondary text if none is specified. [TODO figure out what I meant by this]
|
- Message boxes should not show secondary text if none is specified. [TODO figure out what I meant by this]
|
||||||
- note that you can change event channels before opening the window; this allows unifying menus/toolbars/etc.
|
|
||||||
- will probably want to bring back Event() for this (but as NewEvent())
|
|
||||||
- add bounds checking to Area's sizing methods
|
- add bounds checking to Area's sizing methods
|
||||||
- describe thread-safety of Area.SetSize()
|
- describe thread-safety of Area.SetSize()
|
||||||
- should all instances of -1 as error returns from Windows functions be changed to ^0 or does the uintptr() conversion handle sign extension?
|
- should all instances of -1 as error returns from Windows functions be changed to ^0 or does the uintptr() conversion handle sign extension?
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
type Window struct {
|
type Window struct {
|
||||||
// Closing gets a message when the user clicks the window's close button.
|
// Closing gets a message when the user clicks the window's close button.
|
||||||
// You cannot change it once the Window has been opened.
|
// You cannot change it once the Window has been opened.
|
||||||
|
// If you do not respond to this signal, nothing will happen; regardless of whether you handle the signal or not, the window will not be closed.
|
||||||
Closing chan struct{}
|
Closing chan struct{}
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
Loading…
Reference in New Issue