2024-01-17 23:54:19 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/log"
|
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-18 04:27:19 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-17 23:54:19 -06:00
|
|
|
)
|
|
|
|
|
2024-02-05 12:06:17 -06:00
|
|
|
func setText(n *tree.Node, name string) {
|
|
|
|
// name := widget.GetString(a.Value)
|
2024-01-17 23:54:19 -06:00
|
|
|
var tk *guiWidget
|
|
|
|
tk = n.TK.(*guiWidget)
|
|
|
|
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "setText() START with text =", name, n.WidgetType)
|
2024-01-17 23:54:19 -06:00
|
|
|
if tk == nil {
|
|
|
|
log.Log(ERROR, "setText error. tk == nil", n.GetProgName(), n.WidgetId)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
switch n.WidgetType {
|
|
|
|
case widget.Window:
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "setText() Attempt to set the title to", name)
|
2024-02-05 12:06:17 -06:00
|
|
|
tk.uiWindow.SetTitle(name)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Tab:
|
|
|
|
case widget.Group:
|
2024-02-05 12:06:17 -06:00
|
|
|
tk.uiGroup.SetTitle(name)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Checkbox:
|
2024-02-05 12:06:17 -06:00
|
|
|
tk.uiCheckbox.SetText(name)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Textbox:
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "setText() on Textbox START with text =", name)
|
2024-01-17 23:54:19 -06:00
|
|
|
if tk.uiEntry != nil {
|
|
|
|
tk.uiEntry.SetText(name)
|
|
|
|
}
|
|
|
|
if tk.uiMultilineEntry != nil {
|
|
|
|
tk.uiMultilineEntry.SetText(name)
|
|
|
|
}
|
|
|
|
case widget.Label:
|
2024-02-05 12:06:17 -06:00
|
|
|
tk.uiLabel.SetText(name)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Button:
|
2024-02-05 12:06:17 -06:00
|
|
|
tk.uiButton.SetText(name)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Slider:
|
2024-02-05 12:06:17 -06:00
|
|
|
log.Log(ERROR, "setText() on slider unknown", n.GetProgName())
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Spinner:
|
2024-02-05 12:06:17 -06:00
|
|
|
log.Log(ERROR, "setText() on spinner unknown", n.GetProgName())
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Dropdown:
|
|
|
|
var orig int
|
|
|
|
var i int = -1
|
|
|
|
var s string
|
|
|
|
orig = tk.uiCombobox.Selected()
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "try to set the Dropdown to", name, "from", orig)
|
2024-01-17 23:54:19 -06:00
|
|
|
// try to find the string
|
|
|
|
for i, s = range tk.val {
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "i, s", i, s)
|
2024-01-17 23:54:19 -06:00
|
|
|
if name == s {
|
|
|
|
tk.uiCombobox.SetSelected(i)
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "setText() Dropdown worked.", name)
|
2024-01-17 23:54:19 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Log(ERROR, "setText() Dropdown did not find:", name)
|
|
|
|
// if i == -1, then there are not any things in the menu to select
|
|
|
|
if i == -1 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// if the string was never set, then set the dropdown to the last thing added to the menu
|
|
|
|
if orig == -1 {
|
|
|
|
tk.uiCombobox.SetSelected(i)
|
|
|
|
}
|
|
|
|
case widget.Combobox:
|
|
|
|
tk.uiEditableCombobox.SetText(name)
|
|
|
|
default:
|
2024-02-05 12:06:17 -06:00
|
|
|
log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet")
|
2024-01-17 23:54:19 -06:00
|
|
|
}
|
2024-02-07 07:31:28 -06:00
|
|
|
log.Log(ANDLABS, "setText() END with name =")
|
2024-01-17 23:54:19 -06:00
|
|
|
}
|