summaryrefslogtreecommitdiff
path: root/checkbox.go
blob: 8ba4f8da592a1cbd69e55a637af776e357634011 (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
package gui

import (
	"go.wit.com/log"
	"go.wit.com/widget"
)

func (n *Node) IsChecked() bool {
	return n.checked
}

// deprecate this name
func (n *Node) Checked() bool {
	return n.checked
}

func (n *Node) SetChecked(b bool) *Node {
	// inform the toolkits
	n.checked = b
	sendAction(n, widget.Checked)
	return n
}

func (parent *Node) NewCheckbox(name string) *Node {
	newNode := parent.newNode(name, widget.Checkbox)
	newNode.label = name
	newNode.progname = name

	// setting a default custom value here has
	// been helpful in debugging toolkits
	newNode.Custom = func() {
		log.Log(CHANGE, "checkbox is now", newNode.checked)
	}

	// inform the toolkits
	sendAction(newNode, widget.Add)
	return newNode
}