blob: f89c15ab3a248af80a8e4b9edffe5146b87b7487 (
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
|
package gui
import (
"go.wit.com/log"
"go.wit.com/widget"
)
// tracks dropdown and combobox entries. Makes sure they are unique
func (n *Node) addText(newS string) {
var highest int
for s, i := range n.strings {
if i > highest {
highest = i
}
if s == newS {
return
}
}
n.strings[newS] = highest + 1 // TODO: use the int's for the order
n.newString = newS
// inform the toolkits
sendAction(n, widget.AddText)
}
// add a new text string to widgets that support
// multiple string values
// These must be unique. return false if the string already exists
func (n *Node) AddText(str string) bool {
if !n.Ready() {
return false
}
log.Log(INFO, "AddText() value =", str)
log.Log(INFO, "AddText() value =", str)
log.Log(INFO, "AddText() value =", str)
// for some reason, the n.mu.Lock() doesn't seem to protect the append() function on strings
// switched to a map. I suspect that is what maps are for because they are safer
n.addText(str)
return true
}
|