2024-01-11 00:51:37 -06:00
|
|
|
package gui
|
|
|
|
|
|
|
|
// Common actions for widgets like 'Enable' or 'Hide'
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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)
|
|
|
|
|
|
|
|
n.value = text
|
|
|
|
|
|
|
|
if ! n.hidden {
|
|
|
|
a := newAction(n, widget.SetText)
|
2024-01-11 19:32:40 -06:00
|
|
|
a.Value = n.value
|
2024-01-11 00:51:37 -06:00
|
|
|
sendAction(a)
|
|
|
|
}
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2024-01-11 19:32:40 -06:00
|
|
|
/*
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2024-01-11 00:51:37 -06:00
|
|
|
func (n *Node) Set(val any) {
|
|
|
|
log.Log(CHANGE, "Set() value =", val)
|
|
|
|
|
2024-01-11 19:32:40 -06:00
|
|
|
n.value = val
|
|
|
|
/*
|
2024-01-11 00:51:37 -06:00
|
|
|
n.value = val
|
|
|
|
|
|
|
|
switch v := val.(type) {
|
|
|
|
case bool:
|
|
|
|
n.B = val.(bool)
|
|
|
|
case string:
|
2024-01-11 19:32:40 -06:00
|
|
|
n.label = val.(string)
|
2024-01-11 00:51:37 -06:00
|
|
|
n.S = val.(string)
|
|
|
|
case int:
|
|
|
|
n.I = val.(int)
|
|
|
|
default:
|
|
|
|
log.Error(errors.New("Set() unknown type"), "v =", v)
|
|
|
|
}
|
2024-01-11 19:32:40 -06:00
|
|
|
*/
|
2024-01-11 00:51:37 -06:00
|
|
|
|
|
|
|
if ! n.hidden {
|
|
|
|
a := newAction(n, widget.Set)
|
2024-01-11 19:32:40 -06:00
|
|
|
a.Value = n.value
|
2024-01-11 00:51:37 -06:00
|
|
|
sendAction(a)
|
|
|
|
}
|
|
|
|
}
|