blob: 67b7f4c6fa348633f13a1ead72a58ee50b29b4d9 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
package gui
// Common actions for widgets like 'Enable' or 'Hide'
import (
"go.wit.com/log"
"go.wit.com/widget"
)
// This will set the visable name for widgets that
// have text displayed that is not editable by the user
// For example, a button, window, group, checkbox
func (n *Node) SetLabel(label string) *Node {
switch n.WidgetType {
case widget.Checkbox:
n.label = label
case widget.Button:
n.label = label
case widget.Label:
if n.IsMirror() {
// n is a mirror of something else
log.Log(WARN, "SetLabel() error this widget is a mirror", n.id)
} else {
n.label = label
n.updateMirrors()
}
case widget.Group:
n.label = label
case widget.Window:
n.label = label
default:
}
n.changed = true
log.Log(CHANGE, "SetLabel() =", label)
// inform the toolkits
sendAction(n, widget.SetText)
return n
}
// What "SetText" means depends on the type of widget
// should this be a different name?
func (n *Node) SetText(text string) *Node {
n.newString = text
n.changed = true
log.Log(CHANGE, "SetText() text =", text)
switch n.WidgetType {
case widget.Checkbox:
n.label = text
case widget.Button:
n.label = text
case widget.Label:
n.label = text
case widget.Group:
n.label = text
case widget.Combobox:
n.newString = text
n.currentS = text
n.defaultS = text
case widget.Dropdown:
n.newString = text
n.currentS = text
n.defaultS = text
case widget.Textbox:
n.currentS = text
n.defaultS = text
case widget.Window:
n.label = text
default:
}
// inform the toolkits
sendAction(n, widget.SetText)
return n
}
|