parent
6fb1a5802a
commit
732f3c60e9
25
checkbox.go
25
checkbox.go
|
@ -1,33 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
log "go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func (w *guiWidget) setCheckbox(b any) {
|
||||
// redraw the checkbox
|
||||
func (w *guiWidget) setCheckbox() {
|
||||
if w.node.WidgetType != widget.Checkbox {
|
||||
log.Log(WARN, "setCheckbox() being run on widget:", w.node.WidgetType)
|
||||
return
|
||||
}
|
||||
if w.node.State.Label == "" {
|
||||
w.node.State.Label = "BLANK"
|
||||
}
|
||||
if widget.GetBool(b) {
|
||||
w.checked = widget.GetBool(b)
|
||||
if w.node.State.Checked {
|
||||
log.Log(WARN, "setCheckbox() got true", w.node.State.Checked)
|
||||
w.labelN = "X " + w.node.State.Label
|
||||
// w.changed = true
|
||||
} else {
|
||||
w.checked = widget.GetBool(b)
|
||||
log.Log(WARN, "setCheckbox() got false", w.node.State.Checked)
|
||||
w.labelN = " " + w.node.State.Label
|
||||
// w.changed = true
|
||||
}
|
||||
t := len(w.labelN) + 1
|
||||
w.gocuiSize.w1 = w.gocuiSize.w0 + t
|
||||
|
||||
// w.realWidth = w.gocuiSize.Width() + me.PadW
|
||||
// w.realHeight = w.gocuiSize.Height() + me.PadH
|
||||
|
||||
// if w.frame {
|
||||
// w.realWidth += me.FramePadW
|
||||
// w.realHeight += me.FramePadH
|
||||
// }
|
||||
// t := len(w.labelN) + 3
|
||||
// w.gocuiSize.w1 = w.gocuiSize.w0 + t
|
||||
|
||||
w.deleteView()
|
||||
w.showView()
|
||||
|
|
13
click.go
13
click.go
|
@ -150,13 +150,16 @@ func (w *guiWidget) doWidgetClick() {
|
|||
}
|
||||
// w.dumpTree("click end")
|
||||
case widget.Checkbox:
|
||||
if widget.GetBool(w.value) {
|
||||
w.setCheckbox(false)
|
||||
if w.node.State.Checked {
|
||||
log.Log(WARN, "checkbox is being set to false")
|
||||
w.node.State.Checked = false
|
||||
w.setCheckbox()
|
||||
} else {
|
||||
w.setCheckbox(true)
|
||||
log.Log(WARN, "checkbox is being set to true")
|
||||
w.node.State.Checked = true
|
||||
w.setCheckbox()
|
||||
}
|
||||
// n.doUserEvent()
|
||||
me.myTree.SendUserEvent(me.treeRoot)
|
||||
me.myTree.SendUserEvent(w.node)
|
||||
case widget.Grid:
|
||||
newR := w.realGocuiSize()
|
||||
|
||||
|
|
|
@ -174,7 +174,11 @@ func (w *guiWidget) Set(val any) {
|
|||
log.Log(INFO, "Set() value =", val)
|
||||
|
||||
w.value = val.(string)
|
||||
if w.node.WidgetType != widget.Checkbox {
|
||||
w.setCheckbox(val)
|
||||
if w.node.WidgetType == widget.Checkbox {
|
||||
w.node.State.Checked = widget.GetBool(val)
|
||||
w.setCheckbox()
|
||||
}
|
||||
if w.node.WidgetType == widget.Label {
|
||||
w.labelN = widget.GetString(val)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue