summaryrefslogtreecommitdiff
path: root/andlabs/dropdown.go
diff options
context:
space:
mode:
Diffstat (limited to 'andlabs/dropdown.go')
-rw-r--r--andlabs/dropdown.go69
1 files changed, 38 insertions, 31 deletions
diff --git a/andlabs/dropdown.go b/andlabs/dropdown.go
index d2c493b..a189bf7 100644
--- a/andlabs/dropdown.go
+++ b/andlabs/dropdown.go
@@ -31,50 +31,57 @@ func (p *node) newDropdown(n *node) {
n.doUserEvent()
})
+
n.tk = newt
p.place(n)
-}
-func (t *guiWidget) addDropdownName(title string) {
- t.uiCombobox.Append(title)
- if (t.val == nil) {
- log.Log(INFO, "make map didn't work")
- return
- }
- t.val[t.c] = title
-
- // If this is the first menu added, set the dropdown to it
- if (t.c == 0) {
- log.Log(INFO, "THIS IS THE FIRST Dropdown", title)
- t.uiCombobox.SetSelected(0)
+ // add the initial dropdown entries
+ for i, s := range n.strings {
+ log.Warn("add dropdown: add entries on create", n.progname, i, s)
+ n.addDropdownName(s)
}
- t.c = t.c + 1
+ cur := widget.GetString(n.value)
+ log.Warn("add dropdown: set default value on create", n.progname, cur)
+ n.setDropdownName(cur)
}
-func (t *guiWidget) SetDropdown(i int) {
- t.uiCombobox.SetSelected(i)
+
+func (n *node) SetDropdownInt(i int) {
+ if ! n.ready() { return }
+ n.tk.uiCombobox.SetSelected(i)
}
-func (n *node) AddDropdownName(s string) {
- log.Log(INFO, "AddDropdownName()", n.WidgetId, "add:", s)
+func (n *node) addDropdownName(s string) {
+ if ! n.ready() { return }
+ log.Log(INFO, "addDropdownName()", n.WidgetId, "add:", s)
- t := n.tk
- if (t == nil) {
- log.Log(INFO, "AddDropdownName() toolkit struct == nil. name=", n.progname, s)
+ n.tk.uiCombobox.Append(s)
+ if (n.tk.val == nil) {
+ log.Log(INFO, "make map didn't work")
return
}
- t.addDropdownName(s)
+ n.tk.val[n.tk.c] = s
+
+ // If this is the first menu added, set the dropdown to it
+ if (n.tk.c == 0) {
+ log.Log(INFO, "THIS IS THE FIRST Dropdown", s)
+ n.tk.uiCombobox.SetSelected(0)
+ }
+ n.tk.c = n.tk.c + 1
}
-func (n *node) SetDropdownName(a *widget.Action, s string) {
- log.Log(INFO, "SetDropdown()", n.WidgetId, ",", s)
+func (n *node) setDropdownName(s string) bool {
+ if ! n.ready() { return false}
+ log.Log(INFO, "SetDropdownName()", n.WidgetId, ",", s)
- t := n.tk
- if (t == nil) {
- log.Log(ERROR, "SetDropdown() FAILED mapToolkits[w] == nil. name=", n.WidgetId, s)
- return
+ for i, tmp := range n.tk.val {
+ if s == tmp {
+ n.value = s
+ n.SetDropdownInt(i)
+ log.Warn("SetDropdownInt() worked", tmp, i)
+ return true
+ }
}
- t.SetDropdown(1)
- // TODO: send back to wit/gui goroutine with the chan
- n.value = s
+ log.Warn("SetDropdownName() failed", s)
+ return false
}