|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
package ui |
|
|
|
|
|
|
|
|
|
import "errors" |
|
|
|
|
|
|
|
|
|
// Checkbox combines a CheckButton with a widget like a Label.
|
|
|
|
|
type Checkbox struct { |
|
|
|
|
Frame |
|
|
|
@ -60,6 +62,14 @@ func (w *Checkbox) Child() Widget { |
|
|
|
|
return w.child |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SetText conveniently sets the button text, for Label children only.
|
|
|
|
|
func (w *Checkbox) SetText(text string) error { |
|
|
|
|
if label, ok := w.child.(*Label); ok { |
|
|
|
|
label.Text = text |
|
|
|
|
} |
|
|
|
|
return errors.New("child is not a Label widget") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Pass event handlers on to descendents.
|
|
|
|
|
func (w *Checkbox) Handle(e Event, fn func(EventData) error) { |
|
|
|
|
w.button.Handle(e, fn) |
|
|
|
|