From 49f8e1c043ed5dfe39d0c56a9fd52b20fb069bb2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Feb 2025 15:48:28 -0600 Subject: [PATCH] dropdown menu selects and changes text again --- eventBindings.go | 3 +-- eventMouseClick.go | 15 ++++++++++++--- help.go | 2 +- structs.go | 5 +++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/eventBindings.go b/eventBindings.go index 6812314..04cdd77 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -67,8 +67,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error { w, h := g.MousePosition() for _, tk := range findByXY(w, h) { if tk.node.WidgetType == widget.Stdout { - tk.dumpWidget("theNotsure()") - log.Info("skipping stdout") + tk.dumpWidget("theNotsure() SKIP STDOUT") continue } tk.dumpWidget("theNotsure() HIDDING") diff --git a/eventMouseClick.go b/eventMouseClick.go index a292cc4..c3c960e 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -82,12 +82,13 @@ func (tk *guiWidget) doWidgetClick(w int, h int) { log.Log(GOCUI, "do the dropdown here") tk.showDropdown() me.dropdownW = tk - case widget.Flag: - log.Log(GOCUI, "flag widget found!") - tk.dumpWidget("flag click") case widget.Stdout: log.Log(GOCUI, "stdout widget found!") tk.dumpWidget("stdout click") + case widget.Flag: + log.Log(GOCUI, "flag widget found!") + got := tk.dropdownClicked(w, h) + log.Log(GOCUI, "flag click got", got) default: tk.dumpWidget("blank click()") } @@ -100,6 +101,14 @@ func click(g *gocui.Gui, v *gocui.View) error { w := mouseW h := mouseH + // Flag widgets (dropdown menus, etc) are the highest priority. ALWAYS SEND MOUSE CLICKS THERE FIRST + for _, tk := range findByXY(w, h) { + if tk.node.WidgetType == widget.Flag { + tk.doWidgetClick(w, h) + return nil + } + } + for _, tk := range findByXY(w, h) { // will show you everything found on a mouse click. great for debugging! // tk.dumpWidget("click()") diff --git a/help.go b/help.go index 10ae31c..12e8c9b 100644 --- a/help.go +++ b/help.go @@ -24,7 +24,7 @@ import ( var helpText []string = []string{"KEYBINDINGS", "", - "?: toggle zhelp", + "?: toggle help", "S: super mouse", "M: list all widgets positions", "L: list all widgets in tree form", diff --git a/structs.go b/structs.go index 1f01305..84b0a3a 100644 --- a/structs.go +++ b/structs.go @@ -160,8 +160,9 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { return len(p), nil } -// this sets the `default` in the structs -// this is cool code. thank Alex Flint & other GO devs for this code +// THIS IS GO COMPILER MAGIC +// this sets the `default` in the structs above on init() +// this is cool code. thank the GO devs for this code and Alex Flint for explaining it to me func Set(ptr interface{}, tag string) error { if reflect.TypeOf(ptr).Kind() != reflect.Ptr { log.Log(ERROR, "Set() Not a pointer", ptr, "with tag =", tag)