summaryrefslogtreecommitdiff
path: root/widget.go
diff options
context:
space:
mode:
Diffstat (limited to 'widget.go')
-rw-r--r--widget.go42
1 files changed, 33 insertions, 9 deletions
diff --git a/widget.go b/widget.go
index ec1387c..10f1af9 100644
--- a/widget.go
+++ b/widget.go
@@ -3,6 +3,7 @@ package main
import (
"strconv"
+ "github.com/awesome-gocui/gocui"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
@@ -11,19 +12,13 @@ import (
func initWidget(n *tree.Node) *guiWidget {
var w *guiWidget
w = new(guiWidget)
- // Set(w, "default")
w.node = n
-
- // set the name used by gocui to the id
- // w.cuiName = string(n.WidgetId)
-
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
-
w.WidgetType = n.WidgetType
-
w.labelN = n.State.Label
if w.labelN == "" {
+ // remove this debugging hack once things are stable and fixed
w.labelN = n.GetProgName()
}
w.frame = true
@@ -106,7 +101,6 @@ func (tk *guiWidget) Visible() bool {
if tk.v == nil {
return false
}
- // return tk.v.Visible
tk.v.Visible = true
return true
}
@@ -125,5 +119,35 @@ func (tk *guiWidget) SetVisible(b bool) {
} else {
tk.Hide()
}
- // w.v.Visible = b
+}
+
+func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
+ if tk.cuiName == name {
+ return tk
+ }
+ for _, child := range tk.children {
+ found := child.findWidgetByName(name)
+ if found != nil {
+ return found
+ }
+ }
+ return nil
+}
+
+func (tk *guiWidget) findWidgetByView(v *gocui.View) *guiWidget {
+ if tk.v == v {
+ return tk
+ }
+ if tk.cuiName == v.Name() {
+ log.Log(NOW, "findWidget() error. names are mismatched or out of sync", tk.cuiName)
+ log.Log(NOW, "findWidget() or maybe the view has been deleted")
+ // return tk
+ }
+ for _, child := range tk.children {
+ found := child.findWidgetByView(v)
+ if found != nil {
+ return found
+ }
+ }
+ return nil
}