summaryrefslogtreecommitdiff
path: root/checkbox.go
blob: e7e91e77a49ee690637901eca77004f0507f4390 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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() {
	if tk.WidgetType() != widget.Checkbox {
		log.Log(WARN, "setCheckbox() being run on widget:", tk.WidgetType())
		return
	}
	if tk.Checked() {
		log.Log(WARN, "setCheckbox() got true", tk.Checked())
		tk.labelN = "X " + tk.GetLabel()
	} else {
		log.Log(WARN, "setCheckbox() got false", tk.Checked())
		tk.labelN = "_ " + tk.GetLabel()
	}

	tk.Hide()
	tk.Show()
}