diff options
| author | Jeff Carr <[email protected]> | 2024-01-13 22:02:12 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-13 22:02:12 -0600 |
| commit | 47b15946de10a75cda026a7317a90d4857b453c8 (patch) | |
| tree | ab6a8c085226263982d3b19f2913e540707af2a1 /setText.go | |
| parent | 4ef8409eeadcd4a359b7593b5ea35f9f523bfb64 (diff) | |
work on hiding widgetsv0.12.5
When widgets are hidden, their state works exactly the same
as normal, but updates are not sent to the toolkits
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'setText.go')
| -rw-r--r-- | setText.go | 67 |
1 files changed, 29 insertions, 38 deletions
@@ -3,64 +3,55 @@ package gui // Common actions for widgets like 'Enable' or 'Hide' import ( + "errors" + "go.wit.com/log" "go.wit.com/gui/widget" ) func (n *Node) SetText(text string) *Node { if ! n.Ready() { return n } - log.Log(CHANGE, "SetText() value =", text) + if n.GetText() == text { + // nothing changed + return n + } n.value = text + n.changed = true + log.Log(CHANGE, "SetText() value =", text) - if ! n.hidden { - a := newAction(n, widget.SetText) - a.Value = n.value - sendAction(a) - } + // inform the toolkits + sendAction(n, widget.SetText) return n } -/* -func convertString(val any) string { - switch v := val.(type) { - case bool: - n.B = val.(bool) - case string: - n.label = val.(string) - n.S = val.(string) - case int: - n.I = val.(int) - default: - log.Error(errors.New("Set() unknown type"), "v =", v) - } -} -*/ - - func (n *Node) Set(val any) { - log.Log(CHANGE, "Set() value =", val) - - n.value = val - /* - n.value = val + if ! n.Ready() { return } switch v := val.(type) { case bool: - n.B = val.(bool) + if widget.GetBool(n.value) == val.(bool) { + // nothing changed + return + } case string: - n.label = val.(string) - n.S = val.(string) + if widget.GetString(n.value) == val.(string) { + // nothing changed + return + } case int: - n.I = val.(int) + if widget.GetInt(n.value) == val.(int) { + // nothing changed + return + } default: log.Error(errors.New("Set() unknown type"), "v =", v) } - */ - if ! n.hidden { - a := newAction(n, widget.Set) - a.Value = n.value - sendAction(a) - } + n.value = val + n.changed = true + log.Log(CHANGE, "Set() value =", val) + + // inform the toolkits + sendAction(n, widget.Set) } |
