diff options
Diffstat (limited to 'nocui/common.go')
| -rw-r--r-- | nocui/common.go | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/nocui/common.go b/nocui/common.go index 9a13323..35d8f22 100644 --- a/nocui/common.go +++ b/nocui/common.go @@ -49,6 +49,8 @@ type node struct { // values from things like checkboxes & dropdown's value any + strings []string + // This is used for things like a slider(0,100) X int Y int @@ -106,50 +108,6 @@ func (n *node) doUserEvent() { return } -func addNode(a *widget.Action) *node { - n := new(node) - n.WidgetType = a.WidgetType - n.WidgetId = a.WidgetId - n.ParentId = a.ParentId - - // copy the data from the action message - n.progname = a.ProgName - n.value = a.Value - n.direction = a.Direction - - n.X = a.X - n.Y = a.Y - - n.W = a.W - n.H = a.H - n.AtW = a.AtW - n.AtH = a.AtH - - // store the internal toolkit information - n.tk = initWidget(n) - // n.tk = new(guiWidget) - - if (a.WidgetType == widget.Root) { - log.Log(INFO, "addNode() Root") - return n - } - - if (me.rootNode.findWidgetId(a.WidgetId) != nil) { - log.Log(ERROR, "addNode() WidgetId already exists", a.WidgetId) - return me.rootNode.findWidgetId(a.WidgetId) - } - - // add this new widget on the binary tree - n.parent = me.rootNode.findWidgetId(a.ParentId) - if n.parent != nil { - n.parent.children = append(n.parent.children, n) - //w := n.tk - //w.parent = n.parent.tk - //w.parent.children = append(w.parent.children, w) - } - return n -} - // Other goroutines must use this to access the GUI // // You can not acess / process the GUI thread directly from @@ -181,6 +139,7 @@ func convertString(val any) string { } */ +// this is in common.go, do not move it func getString(A any) string { if A == nil { log.Warn("getString() got nil") @@ -208,3 +167,49 @@ func getString(A any) string { } return "" } + +// this is in common.go, do not move it +func addNode(a *widget.Action) *node { + n := new(node) + n.WidgetType = a.WidgetType + n.WidgetId = a.WidgetId + n.ParentId = a.ParentId + + // copy the data from the action message + n.progname = a.ProgName + n.value = a.Value + n.direction = a.Direction + n.strings = a.Strings + + // TODO: these need to be rethought + n.X = a.X + n.Y = a.Y + n.W = a.W + n.H = a.H + n.AtW = a.AtW + n.AtH = a.AtH + + // store the internal toolkit information + n.tk = initWidget(n) + // n.tk = new(guiWidget) + + if (a.WidgetType == widget.Root) { + log.Log(INFO, "addNode() Root") + return n + } + + if (me.rootNode.findWidgetId(a.WidgetId) != nil) { + log.Log(ERROR, "addNode() WidgetId already exists", a.WidgetId) + return me.rootNode.findWidgetId(a.WidgetId) + } + + // add this new widget on the binary tree + n.parent = me.rootNode.findWidgetId(a.ParentId) + if n.parent != nil { + n.parent.children = append(n.parent.children, n) + //w := n.tk + //w.parent = n.parent.tk + //w.parent.children = append(w.parent.children, w) + } + return n +} |
