45 lines
791 B
Go
45 lines
791 B
Go
package main
|
|
|
|
import (
|
|
"go.wit.com/log"
|
|
"go.wit.com/toolkits/tree"
|
|
"go.wit.com/widget"
|
|
|
|
"go.wit.com/dev/andlabs/ui"
|
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
|
)
|
|
|
|
func newCheckbox(p *tree.Node, n *tree.Node) {
|
|
if notNew(n) {
|
|
return
|
|
}
|
|
newt := new(guiWidget)
|
|
|
|
newt.uiCheckbox = ui.NewCheckbox(n.GetLabel())
|
|
newt.uiControl = newt.uiCheckbox
|
|
|
|
newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) {
|
|
var b bool
|
|
b = newt.checked()
|
|
n.State.Checked = b
|
|
log.Log(ANDLABS, "Checkbox is now =", b)
|
|
me.myTree.SendUserEvent(n)
|
|
})
|
|
|
|
n.TK = newt
|
|
place(p, n)
|
|
}
|
|
|
|
func (t *guiWidget) checked() bool {
|
|
return t.uiCheckbox.Checked()
|
|
}
|
|
|
|
func setChecked(n *tree.Node, b bool) {
|
|
if n.WidgetType != widget.Checkbox {
|
|
}
|
|
var tk *guiWidget
|
|
tk = n.TK.(*guiWidget)
|
|
|
|
tk.uiCheckbox.SetChecked(b)
|
|
}
|