Made event handler setters return a Request, implemented stubs on GTK+ so I can build a test, and made documentation consistent.

This commit is contained in:
Pietro Gagliardi 2014-07-07 16:51:17 -04:00
parent c0c38ac8f5
commit 0c57837676
4 changed files with 14 additions and 8 deletions

View File

@ -15,15 +15,15 @@ type Control interface {
type Button interface {
Control
// OnClicked sets the event handler for when the Button is clicked.
OnClicked(func(d Doer))
// OnClicked creates a Request to set the event handler for when the Button is clicked.
OnClicked(func(d Doer)) *Request
// Text and SetText are Requests that get and set the Button's label text.
// Text and SetText creates a Request that get and set the Button's label text.
Text() *Request
SetText(text string) *Request
}
// NewButton returns a Request to create a new Button with the given label text.
// NewButton creates a Request to create a new Button with the given label text.
func NewButton(text string) *Request {
return newButton(text)
}

View File

@ -40,7 +40,10 @@ func newButton(text string) *Request {
}
}
// TODO OnClicked
func (b *Button) OnClicked(func e(c Doer)) *Request {
// TODO
return nil
}
func (b *button) Text() *Request {
c := make(chan interface{})

View File

@ -22,11 +22,11 @@ type Window interface {
// Attempting to use a Window after it has been closed results in undefined behavior.
Close() *Request
// OnClosing registers an event handler that is triggered when the user clicks the Window's close button.
// OnClosing creates a Request to register an event handler that is triggered when the user clicks the Window's close button.
// On systems where whole applications own windows, OnClosing is also triggered when the user asks to close the application.
// If this handler returns true, the Window is closed as defined by Close above.
// If this handler returns false, the Window is not closed.
OnClosing(func(c Doer) bool)
OnClosing(func(c Doer) bool) *Request
// TODO SetSize (TODO remove?)
// TODO Center

View File

@ -107,4 +107,7 @@ func (w *window) Close() *Request {
}
}
// TODO OnClosing
func (w *window) OnClosing(func e(c Doer) bool) *Request {
// TODO
return nil
}