summaryrefslogtreecommitdiff
path: root/addText.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-17 21:21:29 -0600
committerJeff Carr <[email protected]>2024-01-17 21:21:29 -0600
commita6a3e1193fa7c77165f3ed2eb0031f319b4abdd0 (patch)
tree2c5a9fbf4dbc5f7bd5cb235542082da5eba342c6 /addText.go
parent8ef3fc7a73a004385d36561c6c8acc4be7e3e24b (diff)
work around a toolkit panic()v0.12.11
things should work when GUI is not really there Int() and Bool() helloworld works compiles and runs RawWindow shouldn't auto exit add StandardExit() Signed-off-by: Jeff Carr <[email protected]> Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'addText.go')
-rw-r--r--addText.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/addText.go b/addText.go
new file mode 100644
index 0000000..7f98c63
--- /dev/null
+++ b/addText.go
@@ -0,0 +1,50 @@
+package gui
+
+import (
+ "go.wit.com/log"
+ "go.wit.com/gui/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.value = newS
+ /*
+ // time.Sleep(time.Duration(1000 * time.Nanosecond)) // doesn't work
+ // maybe this stupid chipset is defective. TODO: try on different hardware
+ // tried with go 1.21.4 debian sid
+ mylock.Lock()
+ n.mu.Lock()
+ // time.Sleep(time.Duration(10 * time.Microsecond)) // doesn't work
+ time.Sleep(time.Duration(100 * time.Microsecond)) // does work
+ n.strings = append(n.strings, newS)
+ n.mu.Unlock()
+ mylock.Unlock()
+ log.Warn("addText() has strings:", n.strings)
+ */
+
+ // 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.Warn("AddText() value =", str)
+ log.Warn("AddText() value =", str)
+ log.Warn("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
+}