summaryrefslogtreecommitdiff
path: root/checkbox.go
blob: 0372a50f65f96a752682e0c5e23ecfd003bbe4e0 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package gui

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

/*
This was the old code
	newt.Custom = func () {
		println("AM IN CALLBACK. SETTING NODE.checked START")
		if newt.Checked() {
			println("is checked")
			c.checked = true
		} else {
			println("is not checked")
			c.checked = false
		}
		commonCallback(c)
		println("AM IN CALLBACK. SETTING NODE.checked END")
	}
*/


func (n *Node) NewCheckbox(name string) *Node {
	newNode := n.New(name, "Checkbox")
	newNode.custom = n.custom

	newNode.Widget.Custom = func() {
		log(debugChange, "wit go gui checkbox", newNode.Widget)
		if (n.custom != nil) {
			log(debugChange, "trying parent.custom() callback() name =", name)
			n.custom()
		} else {
			log(debugChange, "wit/gui No parent.custom() function is defined for button name =", name)
		}
		if (newNode.custom != nil) {
			log(debugChange, "trying newNode.custom() callback name =", name)
			newNode.custom()
		} else {
			log(debugChange, "wit/gui No newNode.custom() function is defined for button name =", name)
		}
	}

	for _, aplug := range allPlugins {
		log(debugGui, "gui.NewCheckbox() aplug =", aplug.name, "name =", newNode.Widget.Name)
		if (aplug.NewCheckbox == nil) {
			log(debugGui, "\tgui.NewCheckbox() aplug.NewCheckbox = nil", aplug.name)
			continue
		}
		aplug.NewCheckbox(&n.Widget, &newNode.Widget)
	}

	return newNode
}