diff options
| -rw-r--r-- | common.go | 8 | ||||
| -rw-r--r-- | main.go | 2 | ||||
| -rw-r--r-- | setText.go | 74 |
3 files changed, 23 insertions, 61 deletions
@@ -125,6 +125,14 @@ func (n *Node) SetBool(b bool) { } } +func (n *Node) SetInt(i int) { + switch n.WidgetType { + default: + n.value = i + // log.Warn("WidgetType not bool", n.WidgetType, n.id) + } +} + func (n *Node) String() string { if !n.Ready() { return "" @@ -143,7 +143,7 @@ func (n *Node) gotUserEvent(a widget.Action) { default: } - n.SetValue(a.Value) + n.value = a.Value log.Log(CHANGE, "gotUserEvent() n.Bool() =", n.Bool(), "n.String() =", n.String()) if n.Custom == nil { log.Log(CHANGE, "a Custom() function was not set for this widget") @@ -36,71 +36,25 @@ func (n *Node) SetLabel(label string) *Node { // What "SetText" means depends on the type of widget // should this be a different name? func (n *Node) SetText(text string) *Node { - n.SetValue(text) - /* - if !n.Ready() { - return n - } - - if n.String() == text { - // nothing changed - // return n - } - n.value = text - n.changed = true - log.Log(CHANGE, "SetText() value =", text) - - // inform the toolkits - sendAction(n, widget.SetText) - */ - return n -} - -func (n *Node) SetValue(val any) *Node { - if !n.Ready() { - return n - } - - n.value = val + n.value = text n.changed = true - log.Log(CHANGE, "Set() value =", val) - - // inform the toolkits - sendAction(n, widget.Set) - return n -} + log.Log(CHANGE, "SetText() text =", text) -/* -func (n *Node) Set(val any) { - if !n.Ready() { - return - } - - switch v := val.(type) { - case bool: - if widget.GetBool(n.value) == val.(bool) { - // nothing changed - return - } - case string: - if widget.GetString(n.value) == val.(string) { - // nothing changed - return - } - case int: - if widget.GetInt(n.value) == val.(int) { - // nothing changed - return - } + switch n.WidgetType { + case widget.Checkbox: + n.label = text + case widget.Button: + n.label = text + case widget.Label: + n.label = text + case widget.Group: + n.label = text + case widget.Window: + n.label = text default: - log.Error(errors.New("Set() unknown type"), "v =", v) } - n.value = val - n.changed = true - log.Log(CHANGE, "Set() value =", val) - // inform the toolkits sendAction(n, widget.Set) + return n } -*/ |
