gocui/checkbox.go

41 lines
836 B
Go
Raw Normal View History

2025-02-01 11:42:31 -06:00
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
log "go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
// this comes from the application
func setChecked(n *tree.Node, b bool) {
if n.WidgetType != widget.Checkbox {
}
n.State.Checked = b
var tk *guiWidget
tk = n.TK.(*guiWidget)
tk.setCheckbox()
}
// redraw the checkbox
func (tk *guiWidget) setCheckbox() {
2025-02-19 04:06:27 -06:00
if tk.WidgetType() != widget.Checkbox {
log.Log(WARN, "setCheckbox() being run on widget:", tk.WidgetType())
return
}
2025-02-19 04:06:27 -06:00
if tk.Checked() {
log.Log(WARN, "setCheckbox() got true", tk.Checked())
tk.labelN = "X " + tk.GetLabel()
} else {
2025-02-19 04:06:27 -06:00
log.Log(WARN, "setCheckbox() got false", tk.Checked())
tk.labelN = "_ " + tk.GetLabel()
}
tk.Hide()
tk.Show()
}