diff options
Diffstat (limited to 'andlabs/setText.go')
| -rw-r--r-- | andlabs/setText.go | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/andlabs/setText.go b/andlabs/setText.go index 77beb5c..c5453db 100644 --- a/andlabs/setText.go +++ b/andlabs/setText.go @@ -3,15 +3,18 @@ package main import ( "go.wit.com/log" "go.wit.com/gui/widget" + "go.wit.com/gui/toolkits/tree" ) -func (n *node) setText(a *widget.Action) { +// func (n *node) setText(a *widget.Action) { +func setText(n *tree.Node, a *widget.Action) { name := widget.GetString(a.Value) + var tk *guiWidget + tk = n.TK.(*guiWidget) log.Log(CHANGE, "setText() START with text =", name) - t := n.tk - if (t == nil) { - log.Log(ERROR, "setText error. tk == nil", n.progname, n.WidgetId) + if (tk == nil) { + log.Log(ERROR, "setText error. tk == nil", n.GetProgName(), n.WidgetId) return } log.Log(CHANGE, "setText() Attempt on", n.WidgetType, "with", name) @@ -19,38 +22,38 @@ func (n *node) setText(a *widget.Action) { switch n.WidgetType { case widget.Window: log.Warn("setText() Attempt to set the title to", name) - t.uiWindow.SetTitle(name) + tk.uiWindow.SetTitle(name) case widget.Tab: case widget.Group: - t.uiGroup.SetTitle(name) + tk.uiGroup.SetTitle(name) case widget.Checkbox: - t.uiCheckbox.SetText(name) + tk.uiCheckbox.SetText(name) case widget.Textbox: - if (t.uiEntry != nil) { - t.uiEntry.SetText(name) + if (tk.uiEntry != nil) { + tk.uiEntry.SetText(name) } - if (t.uiMultilineEntry != nil) { - t.uiMultilineEntry.SetText(name) + if (tk.uiMultilineEntry != nil) { + tk.uiMultilineEntry.SetText(name) } case widget.Label: - t.uiLabel.SetText(name) + tk.uiLabel.SetText(name) case widget.Button: - t.uiButton.SetText(name) + tk.uiButton.SetText(name) case widget.Slider: - log.Log(ERROR, "setText() on slider unknown", a.ActionType, "on checkbox", n.progname) + log.Log(ERROR, "setText() on slider unknown", a.ActionType, "on checkbox", n.GetProgName()) case widget.Spinner: - log.Log(ERROR, "setText() on spinner unknown", a.ActionType, "on checkbox", n.progname) + log.Log(ERROR, "setText() on spinner unknown", a.ActionType, "on checkbox", n.GetProgName()) case widget.Dropdown: var orig int var i int = -1 var s string - orig = t.uiCombobox.Selected() + orig = tk.uiCombobox.Selected() log.Log(CHANGE, "try to set the Dropdown to", name, "from", orig) // try to find the string - for i, s = range t.val { + for i, s = range tk.val { log.Log(CHANGE, "i, s", i, s) if (name == s) { - t.uiCombobox.SetSelected(i) + tk.uiCombobox.SetSelected(i) log.Log(CHANGE, "setText() Dropdown worked.", name) return } @@ -62,10 +65,10 @@ func (n *node) setText(a *widget.Action) { } // 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) + tk.uiCombobox.SetSelected(i) } case widget.Combobox: - t.uiEditableCombobox.SetText(name) + tk.uiEditableCombobox.SetText(name) default: log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType) } |
