summaryrefslogtreecommitdiff
path: root/click.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-02 14:49:17 -0600
committerJeff Carr <[email protected]>2024-02-02 14:49:17 -0600
commitee0f84fd8ef5993a6c374c8ee4e22c837ca39d97 (patch)
tree6b3f2800ddeb92c32d08c537cf1b0c1692b4a166 /click.go
parent4800fe662002c1e0192614f60c179b6d46c43cae (diff)
finds the item chosen from the dropdown list
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'click.go')
-rw-r--r--click.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/click.go b/click.go
index 57a6179..59d33b3 100644
--- a/click.go
+++ b/click.go
@@ -231,16 +231,34 @@ func click(g *gocui.Gui, v *gocui.View) error {
log.Error(errors.New("click() could not find widget for view =" + v.Name()))
} else {
log.Log(NOW, "click() Found widget =", w.node.WidgetId, w.String(), ",", w.labelN)
- if w.String() == "DropBox" {
- log.Log(NOW, "click() this is the dropdown menu. set a flag here what did I click? where is the mouse?")
- log.Log(NOW, "click() set a global dropdown clicked flag=true here")
- }
w.doWidgetClick()
}
+ rootTK := me.treeRoot.TK.(*guiWidget)
+ realTK := rootTK.findWidgetByView(v)
+ if realTK == nil {
+ log.Error(errors.New("toolkit click() out of reality with gocui. v.Name() not in binary tree " + v.Name()))
+ log.Log(NOW, "click() END FAILURE ON gocui v.Name =", v.Name())
+ // return nil // otherwise gocui exits
+ }
+
+ // double check the widget view really still exists
+ nameTK := rootTK.findWidgetByName(v.Name())
+ if nameTK == nil {
+ log.Error(errors.New("toolkit click() out of reality with gocui. v.Name() not in binary tree " + v.Name()))
+ return nil
+ }
+ if nameTK.v == nil {
+ log.Log(NOW, "click() maybe this widget has had it's view distroyed?", nameTK.cuiName, nameTK.WidgetType)
+ log.Log(NOW, "yep. it's gone now")
+ return nil
+ }
+
+ // SetCurrentView dies if it's sent an non-existent view
if _, err := g.SetCurrentView(v.Name()); err != nil {
log.Log(NOW, "click() END v.Name =", v.Name(), "err =", err)
- return err
+ // return err // return causes gocui.MainLoop() to exit. Do we ever want that to happen here?
+ return nil
}
log.Log(NOW, "click() END gocui name:", v.Name())