gui/checkbox.go

34 lines
636 B
Go

package gui
import (
"go.wit.com/log"
"go.wit.com/widget"
)
func (n *Node) Checked() bool {
return n.checked
}
func (n *Node) SetChecked(b bool) *Node {
// inform the toolkits
n.checked = b
sendAction(n, widget.Checked)
return n
}
func (parent *Node) NewCheckbox(name string) *Node {
newNode := parent.newNode(name, widget.Checkbox)
newNode.label = name
newNode.progname = name
// setting a default custom value here has
// been helpful in debugging toolkits
newNode.Custom = func() {
log.Log(CHANGE, "checkbox is now", newNode.checked)
}
// inform the toolkits
sendAction(newNode, widget.Add)
return newNode
}