summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.go8
-rw-r--r--main.go2
-rw-r--r--setText.go74
3 files changed, 23 insertions, 61 deletions
diff --git a/common.go b/common.go
index dc77989..bd999a4 100644
--- a/common.go
+++ b/common.go
@@ -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 ""
diff --git a/main.go b/main.go
index dcbf755..dc43d26 100644
--- a/main.go
+++ b/main.go
@@ -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")
diff --git a/setText.go b/setText.go
index 74d70a9..644fe5f 100644
--- a/setText.go
+++ b/setText.go
@@ -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
}
-*/