summaryrefslogtreecommitdiff
path: root/button.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-03 10:26:47 -0500
committerJeff Carr <[email protected]>2023-04-03 10:26:47 -0500
commit4b6207743b90968d6b822032a4355e43b6ce6da9 (patch)
tree2cb9f13d5e95f14e165f8e41e8484320b7454177 /button.go
parent0320ebe4bb49ea80761d77af80fa208157ffdb89 (diff)
gocui: working towards correct layout
make a gocui widget binary tree more debugging cleanups sample button app displays in gocui geometry logic closer to correct improvements in gocui layout continued attempts to clean up tabs dump binary tree moving towards proper chan callback() deprecate Widget.Name Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'button.go')
-rw-r--r--button.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/button.go b/button.go
index a6026a1..8820734 100644
--- a/button.go
+++ b/button.go
@@ -15,6 +15,35 @@ func (n *Node) NewButton(name string, custom func()) *Node {
return newNode
}
-func callback(i int) {
- log(debugError, "button callback() i =", i)
+func callback(i int) bool {
+ log(debugError, "callback() for widget id =", i)
+ n := Config.rootNode.FindId(i)
+ log(debugError, "callback() found node =", n)
+ // running custom here means the button get's clicked twice
+ if (n.Custom == nil) {
+ log(debugError, "callback() = nil. SKIPPING")
+ return false
+ }
+ n.Custom()
+ return true
}
+
+// find widget by number
+func (n *Node) FindId(i int) (*Node) {
+ if (n == nil) {
+ return nil
+ }
+
+ if (n.id == i) {
+ return n
+ }
+
+ for _, child := range n.children {
+ newN := child.FindId(i)
+ if (newN != nil) {
+ return newN
+ }
+ }
+ return nil
+}
+