working on removing newaction()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-05-09 19:04:39 -05:00
parent 761250d24c
commit 6b55526fee
3 changed files with 18 additions and 10 deletions

View File

@ -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) {

View File

@ -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)

View File

@ -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 (