move towards var value any
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3b402b28d1
commit
4bf3307671
|
@ -1,96 +1,92 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/gui/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) setText(a *widget.Action) {
|
func (n *node) setText(a *widget.Action) {
|
||||||
log.Log(CHANGE, "setText() START with a.S =", a.S)
|
var name string
|
||||||
|
var A any
|
||||||
|
var k reflect.Kind
|
||||||
|
A = a.A
|
||||||
|
if a.A == nil {
|
||||||
|
log.Warn("setText a.A == nil")
|
||||||
|
A = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
k = reflect.TypeOf(A).Kind()
|
||||||
|
|
||||||
|
switch k {
|
||||||
|
case reflect.Int:
|
||||||
|
var i int
|
||||||
|
i = A.(int)
|
||||||
|
name = strconv.Itoa(i)
|
||||||
|
case reflect.String:
|
||||||
|
name = A.(string)
|
||||||
|
case reflect.Bool:
|
||||||
|
if A.(bool) == true {
|
||||||
|
name = "true"
|
||||||
|
} else {
|
||||||
|
name = "false"
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.Warn("setText uknown kind", k, "value =", A)
|
||||||
|
name = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Log(CHANGE, "setText() START with text =", name)
|
||||||
t := n.tk
|
t := n.tk
|
||||||
if (t == nil) {
|
if (t == nil) {
|
||||||
log.Log(ERROR, "setText error. tk == nil", n.Name, n.WidgetId)
|
log.Log(ERROR, "setText error. tk == nil", n.Name, n.WidgetId)
|
||||||
actionDump(debugError, a)
|
actionDump(debugError, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Log(CHANGE, "setText() Attempt on", n.WidgetType, "with", a.S)
|
log.Log(CHANGE, "setText() Attempt on", n.WidgetType, "with", name)
|
||||||
|
|
||||||
switch n.WidgetType {
|
switch n.WidgetType {
|
||||||
case widget.Window:
|
case widget.Window:
|
||||||
log.Warn("setText() Attempt to set the title to", a.S)
|
log.Warn("setText() Attempt to set the title to", name)
|
||||||
t.uiWindow.SetTitle(a.S)
|
t.uiWindow.SetTitle(name)
|
||||||
case widget.Tab:
|
case widget.Tab:
|
||||||
case widget.Group:
|
case widget.Group:
|
||||||
t.uiGroup.SetTitle(a.S)
|
t.uiGroup.SetTitle(name)
|
||||||
case widget.Checkbox:
|
case widget.Checkbox:
|
||||||
switch a.ActionType {
|
t.uiCheckbox.SetText(name)
|
||||||
case widget.SetText:
|
|
||||||
t.uiCheckbox.SetText(a.S)
|
|
||||||
case widget.Get:
|
|
||||||
n.B = t.uiCheckbox.Checked()
|
|
||||||
case widget.Set:
|
|
||||||
// TODO: commented out while working on chan
|
|
||||||
t.uiCheckbox.SetChecked(a.B)
|
|
||||||
default:
|
|
||||||
log.Log(ERROR, "setText() unknown", a.ActionType, "on checkbox", n.Name)
|
|
||||||
}
|
|
||||||
case widget.Textbox:
|
case widget.Textbox:
|
||||||
switch a.ActionType {
|
if (t.uiEntry != nil) {
|
||||||
case widget.Set:
|
t.uiEntry.SetText(name)
|
||||||
if (t.uiEntry != nil) {
|
}
|
||||||
t.uiEntry.SetText(a.S)
|
if (t.uiMultilineEntry != nil) {
|
||||||
}
|
t.uiMultilineEntry.SetText(name)
|
||||||
if (t.uiMultilineEntry != nil) {
|
|
||||||
t.uiMultilineEntry.SetText(a.S)
|
|
||||||
}
|
|
||||||
case widget.SetText:
|
|
||||||
if (t.uiEntry != nil) {
|
|
||||||
t.uiEntry.SetText(a.S)
|
|
||||||
}
|
|
||||||
if (t.uiMultilineEntry != nil) {
|
|
||||||
t.uiMultilineEntry.SetText(a.S)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
log.Log(ERROR, "setText() unknown", a.ActionType, "on checkbox", n.Name)
|
|
||||||
}
|
}
|
||||||
case widget.Label:
|
case widget.Label:
|
||||||
t.uiLabel.SetText(a.S)
|
t.uiLabel.SetText(name)
|
||||||
case widget.Button:
|
case widget.Button:
|
||||||
t.uiButton.SetText(a.S)
|
t.uiButton.SetText(name)
|
||||||
case widget.Slider:
|
case widget.Slider:
|
||||||
switch a.ActionType {
|
log.Log(ERROR, "setText() on slider unknown", a.ActionType, "on checkbox", n.Name)
|
||||||
case widget.Get:
|
|
||||||
n.I = t.uiSlider.Value()
|
|
||||||
case widget.Set:
|
|
||||||
t.uiSlider.SetValue(a.I)
|
|
||||||
default:
|
|
||||||
log.Log(ERROR, "setText() unknown", a.ActionType, "on checkbox", n.Name)
|
|
||||||
}
|
|
||||||
case widget.Spinner:
|
case widget.Spinner:
|
||||||
switch a.ActionType {
|
log.Log(ERROR, "setText() on spinner unknown", a.ActionType, "on checkbox", n.Name)
|
||||||
case widget.Get:
|
|
||||||
n.I = t.uiSpinbox.Value()
|
|
||||||
case widget.Set:
|
|
||||||
t.uiSpinbox.SetValue(a.I)
|
|
||||||
default:
|
|
||||||
log.Log(ERROR, "setText() unknown", a.ActionType, "on checkbox", n.Name)
|
|
||||||
}
|
|
||||||
case widget.Dropdown:
|
case widget.Dropdown:
|
||||||
var orig int
|
var orig int
|
||||||
var i int = -1
|
var i int = -1
|
||||||
var s string
|
var s string
|
||||||
orig = t.uiCombobox.Selected()
|
orig = t.uiCombobox.Selected()
|
||||||
log.Log(CHANGE, "try to set the Dropdown to", a.S, "from", orig)
|
log.Log(CHANGE, "try to set the Dropdown to", name, "from", orig)
|
||||||
// try to find the string
|
// try to find the string
|
||||||
for i, s = range t.val {
|
for i, s = range t.val {
|
||||||
log.Log(CHANGE, "i, s", i, s)
|
log.Log(CHANGE, "i, s", i, s)
|
||||||
if (a.S == s) {
|
if (name == s) {
|
||||||
t.uiCombobox.SetSelected(i)
|
t.uiCombobox.SetSelected(i)
|
||||||
log.Log(CHANGE, "setText() Dropdown worked.", n.S)
|
log.Log(CHANGE, "setText() Dropdown worked.", name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Log(ERROR, "setText() Dropdown did not find:", a.S)
|
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, then there are not any things in the menu to select
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
return
|
return
|
||||||
|
@ -100,20 +96,9 @@ func (n *node) setText(a *widget.Action) {
|
||||||
t.uiCombobox.SetSelected(i)
|
t.uiCombobox.SetSelected(i)
|
||||||
}
|
}
|
||||||
case widget.Combobox:
|
case widget.Combobox:
|
||||||
switch a.ActionType {
|
t.uiEditableCombobox.SetText(name)
|
||||||
case widget.AddText:
|
|
||||||
t.AddComboboxName(a.S)
|
|
||||||
case widget.Set:
|
|
||||||
t.uiEditableCombobox.SetText(a.S)
|
|
||||||
n.S = a.S
|
|
||||||
case widget.SetText:
|
|
||||||
t.uiEditableCombobox.SetText(a.S)
|
|
||||||
n.S = a.S
|
|
||||||
default:
|
|
||||||
log.Log(ERROR, "setText() unknown", a.ActionType, "on checkbox", n.Name)
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType)
|
log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType)
|
||||||
}
|
}
|
||||||
log.Log(CHANGE, "setText() END with a.S =", a.S)
|
log.Log(CHANGE, "setText() END with name =", )
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue