andlabs/addText.go

44 lines
1.0 KiB
Go

package main
import (
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
func compareStrings(n *tree.Node, ss []string) {
}
func addText(n *tree.Node, s string) {
var tk *guiWidget
tk = n.TK.(*guiWidget)
log.Log(ANDLABS, "addText() START with s =", s)
if tk == nil {
log.Log(ERROR, "addText error. tk == nil", n.State.ProgName, n.WidgetId)
return
}
log.Log(ANDLABS, "addText() Attempt on", n.WidgetType, "with", s)
switch n.WidgetType {
case widget.Dropdown:
for i, s := range n.State.Strings {
log.Log(ANDLABS, "n.State.Strings =", i, s)
_, ok := n.Strings[s]
// If the key exists
if ok {
log.Log(ANDLABS, "string is already in the dropdown", i, s)
} else {
log.Log(ANDLABS, "adding new string to dropdown", i, s)
addDropdownName(n, s)
// TODO: make numbers
n.Strings[s] = 21
}
}
case widget.Combobox:
addComboboxName(n, s)
default:
log.Log(ERROR, "addText() doesn't work on", n.WidgetType)
}
log.Log(ANDLABS, "addText() END with =", s)
}