2024-01-01 16:11:54 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-08 21:19:42 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-05 13:30:00 -06:00
|
|
|
"go.wit.com/gui/widget"
|
2024-01-01 16:11:54 -06:00
|
|
|
)
|
|
|
|
|
2024-01-05 13:30:00 -06:00
|
|
|
func (n *node) setText(a *widget.Action) {
|
2024-01-11 17:19:47 -06:00
|
|
|
name := getString(a.Value)
|
2024-01-11 00:52:49 -06:00
|
|
|
|
|
|
|
log.Log(CHANGE, "setText() START with text =", name)
|
2024-01-01 16:11:54 -06:00
|
|
|
t := n.tk
|
|
|
|
if (t == nil) {
|
2024-01-11 17:19:47 -06:00
|
|
|
log.Log(ERROR, "setText error. tk == nil", n.progname, n.WidgetId)
|
2024-01-01 16:11:54 -06:00
|
|
|
return
|
|
|
|
}
|
2024-01-11 00:52:49 -06:00
|
|
|
log.Log(CHANGE, "setText() Attempt on", n.WidgetType, "with", name)
|
2024-01-01 16:11:54 -06:00
|
|
|
|
|
|
|
switch n.WidgetType {
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Window:
|
2024-01-11 00:52:49 -06:00
|
|
|
log.Warn("setText() Attempt to set the title to", name)
|
|
|
|
t.uiWindow.SetTitle(name)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Tab:
|
|
|
|
case widget.Group:
|
2024-01-11 00:52:49 -06:00
|
|
|
t.uiGroup.SetTitle(name)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Checkbox:
|
2024-01-11 00:52:49 -06:00
|
|
|
t.uiCheckbox.SetText(name)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Textbox:
|
2024-01-11 00:52:49 -06:00
|
|
|
if (t.uiEntry != nil) {
|
|
|
|
t.uiEntry.SetText(name)
|
|
|
|
}
|
|
|
|
if (t.uiMultilineEntry != nil) {
|
|
|
|
t.uiMultilineEntry.SetText(name)
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Label:
|
2024-01-11 00:52:49 -06:00
|
|
|
t.uiLabel.SetText(name)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Button:
|
2024-01-11 00:52:49 -06:00
|
|
|
t.uiButton.SetText(name)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Slider:
|
2024-01-11 17:19:47 -06:00
|
|
|
log.Log(ERROR, "setText() on slider unknown", a.ActionType, "on checkbox", n.progname)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Spinner:
|
2024-01-11 17:19:47 -06:00
|
|
|
log.Log(ERROR, "setText() on spinner unknown", a.ActionType, "on checkbox", n.progname)
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Dropdown:
|
2024-01-10 15:35:42 -06:00
|
|
|
var orig int
|
|
|
|
var i int = -1
|
|
|
|
var s string
|
|
|
|
orig = t.uiCombobox.Selected()
|
2024-01-11 00:52:49 -06:00
|
|
|
log.Log(CHANGE, "try to set the Dropdown to", name, "from", orig)
|
2024-01-10 15:35:42 -06:00
|
|
|
// try to find the string
|
|
|
|
for i, s = range t.val {
|
|
|
|
log.Log(CHANGE, "i, s", i, s)
|
2024-01-11 00:52:49 -06:00
|
|
|
if (name == s) {
|
2024-01-01 16:11:54 -06:00
|
|
|
t.uiCombobox.SetSelected(i)
|
2024-01-11 00:52:49 -06:00
|
|
|
log.Log(CHANGE, "setText() Dropdown worked.", name)
|
2024-01-10 15:35:42 -06:00
|
|
|
return
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|
2024-01-10 15:35:42 -06:00
|
|
|
}
|
2024-01-11 00:52:49 -06:00
|
|
|
log.Log(ERROR, "setText() Dropdown did not find:", name)
|
2024-01-10 15:35:42 -06:00
|
|
|
// 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) {
|
|
|
|
t.uiCombobox.SetSelected(i)
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Combobox:
|
2024-01-11 00:52:49 -06:00
|
|
|
t.uiEditableCombobox.SetText(name)
|
2024-01-01 16:11:54 -06:00
|
|
|
default:
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType)
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|
2024-01-11 00:52:49 -06:00
|
|
|
log.Log(CHANGE, "setText() END with name =", )
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|