summaryrefslogtreecommitdiff
path: root/action.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-05 12:06:17 -0600
committerJeff Carr <[email protected]>2024-02-05 12:06:17 -0600
commit1e98d2607b0eafb698dc63e7b97d55ecaf416cb5 (patch)
tree001ec93a75bd26668f7312e45b3f21903181ec8f /action.go
parentfea47363e00f9c02497108484500ad40a88f466c (diff)
use the new tree functions
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'action.go')
-rw-r--r--action.go79
1 files changed, 77 insertions, 2 deletions
diff --git a/action.go b/action.go
index 5799d37..8cb749e 100644
--- a/action.go
+++ b/action.go
@@ -1,8 +1,7 @@
package main
import (
- "errors"
-
+ "go.wit.com/dev/andlabs/ui"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
@@ -169,6 +168,7 @@ func widgetDelete(n *tree.Node) {
}
}
+/*
func processAction(a *widget.Action) {
log.Log(ANDLABS, "processAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
@@ -278,3 +278,78 @@ func processAction(a *widget.Action) {
}
log.Log(INFO, "processAction() END =", a.ActionType, a.WidgetType)
}
+*/
+
+func SetTitle(n *tree.Node, s string) {
+ SetText(n, s)
+}
+
+func SetLabel(n *tree.Node, s string) {
+ SetText(n, s)
+}
+
+func SetText(n *tree.Node, s string) {
+ if n == nil {
+ log.Warn("Tree Error: Add() sent n == nil")
+ return
+ }
+ if n.TK == nil {
+ log.Warn("Tree sent an action on a widget we didn't seem to have.")
+ return
+ }
+ setText(n, s)
+ log.Info("SetText() (new)", n.WidgetType, n.String(), s)
+}
+
+func AddText(n *tree.Node, s string) {
+ if n == nil {
+ log.Warn("Tree Error: Add() sent n == nil")
+ return
+ }
+ if n.TK == nil {
+ log.Warn("Tree sent an action on a widget we didn't seem to have.")
+ return
+ }
+ log.Info("AddText()", n.WidgetType, n.String())
+ // w := n.TK.(*guiWidget)
+ // w.AddText(s)
+ addText(n, s)
+}
+
+func newAction(n *tree.Node, atype widget.ActionType) {
+ log.Log(INFO, "newaction() START", atype)
+ if n == nil {
+ log.Warn("Tree Error: Add() sent n == nil")
+ return
+ }
+ if n.TK == nil {
+ log.Warn("Tree sent an action on a widget we didn't seem to have.")
+ // do this init here again? Probably something
+ // went wrong and we should reset the our while gocui.View tree
+ n.TK = initWidget(n)
+ }
+ // w := n.TK.(*guiWidget)
+ switch atype {
+ case widget.Show:
+ log.Log(NOW, "Show() HERE. a.Hidden() was =", n.Hidden())
+ show(n, true)
+ case widget.Hide:
+ log.Log(NOW, "Hide() HERE. a.State.Hidden was =", n.Hidden())
+ hide(n)
+ case widget.Move:
+ log.Log(NOW, "attempt to move() =", atype, n.WidgetType, n.ProgName())
+ case widget.ToolkitClose:
+ log.Log(NOW, "attempting to Quit andlabs.ui")
+ // standardClose()
+ ui.Quit()
+ case widget.Enable:
+ enable(n, true)
+ case widget.Disable:
+ enable(n, false)
+ case widget.Delete:
+ widgetDelete(n)
+ default:
+ log.Log(ERROR, "newaction() UNHANDLED Action Type =", atype, "WidgetType =", n.WidgetType, "Name =", n.ProgName())
+ }
+ log.Log(INFO, "newaction() END", atype, n.String())
+}