2024-01-17 23:54:19 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-19 02:52:57 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-17 23:54:19 -06:00
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-19 12:18:11 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-17 23:54:19 -06:00
|
|
|
|
|
|
|
"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) {
|
2024-01-19 02:52:57 -06:00
|
|
|
var b bool
|
|
|
|
b = newt.checked()
|
2024-02-05 15:04:01 -06:00
|
|
|
n.State.Checked = b
|
2024-01-21 11:30:12 -06:00
|
|
|
log.Log(ANDLABS, "Checkbox is now =", b)
|
2024-01-19 02:52:57 -06:00
|
|
|
me.myTree.SendUserEvent(n)
|
2024-01-17 23:54:19 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
n.TK = newt
|
|
|
|
place(p, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *guiWidget) checked() bool {
|
|
|
|
return t.uiCheckbox.Checked()
|
|
|
|
}
|
2024-01-19 12:18:11 -06:00
|
|
|
|
|
|
|
func setChecked(n *tree.Node, b bool) {
|
|
|
|
if n.WidgetType != widget.Checkbox {
|
|
|
|
}
|
|
|
|
var tk *guiWidget
|
|
|
|
tk = n.TK.(*guiWidget)
|
|
|
|
|
|
|
|
tk.uiCheckbox.SetChecked(b)
|
|
|
|
}
|