diff --git a/common.go b/common.go index a5997fe..25e25e3 100644 --- a/common.go +++ b/common.go @@ -75,24 +75,21 @@ func (n *Node) SetNext(w int, h int) { func (n *Node) Set(val any) { log(debugChange, "Set() value =", val) - var a toolkit.Action - a.ActionType = toolkit.Set switch v := val.(type) { case bool: n.B = val.(bool) - a.B = val.(bool) case string: n.Text = val.(string) - a.S = val.(string) + n.S = val.(string) case int: n.I = val.(int) - a.I = val.(int) default: - log(debugError, "Set() unknown type =", v, "a =", a) + log(debugError, "Set() unknown type =", v) } - newaction(&a, n, nil) + a := newAction(n, toolkit.Set) + sendAction(a) } func (n *Node) AppendText(str string) { diff --git a/plugin.go b/plugin.go index 207cd4b..c9e0466 100644 --- a/plugin.go +++ b/plugin.go @@ -212,9 +212,17 @@ func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action { a.Name = n.Name a.Text = n.Text a.WidgetId = n.id + a.B = n.B + a.I = n.I + a.S = n.S + a.X = n.X a.Y = n.Y + + a.AtW = n.AtW + a.AtH = n.AtH + if (n.parent != nil) { a.ParentId = n.parent.id } @@ -222,6 +230,7 @@ func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action { return &a } +// sends the action/event to each toolkit via a golang plugin channel func sendAction(a *toolkit.Action) { for _, aplug := range allPlugins { log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType) diff --git a/toolkit/widget.go b/toolkit/widget.go index 4806f1c..655a0db 100644 --- a/toolkit/widget.go +++ b/toolkit/widget.go @@ -32,21 +32,23 @@ type Action struct { I int S string - A any // switch to this or deprecate this? pros/cons? - // This is used for things like a slider(0,100) X int Y int - // This is used for the widget's grid position + // This is for the grid size & widget position W int H int + AtW int + AtH int // Put space around elements to improve look & feel Margin bool // Make widgets fill up the space available Expand bool + + A any // switch to this or deprecate this? pros/cons? } const (