dropdown menu selects and changes text again

This commit is contained in:
Jeff Carr 2025-02-01 15:48:28 -06:00
parent 4bc9fa41b7
commit 49f8e1c043
4 changed files with 17 additions and 8 deletions

View File

@ -67,8 +67,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
w, h := g.MousePosition() w, h := g.MousePosition()
for _, tk := range findByXY(w, h) { for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Stdout { if tk.node.WidgetType == widget.Stdout {
tk.dumpWidget("theNotsure()") tk.dumpWidget("theNotsure() SKIP STDOUT")
log.Info("skipping stdout")
continue continue
} }
tk.dumpWidget("theNotsure() HIDDING") tk.dumpWidget("theNotsure() HIDDING")

View File

@ -82,12 +82,13 @@ func (tk *guiWidget) doWidgetClick(w int, h int) {
log.Log(GOCUI, "do the dropdown here") log.Log(GOCUI, "do the dropdown here")
tk.showDropdown() tk.showDropdown()
me.dropdownW = tk me.dropdownW = tk
case widget.Flag:
log.Log(GOCUI, "flag widget found!")
tk.dumpWidget("flag click")
case widget.Stdout: case widget.Stdout:
log.Log(GOCUI, "stdout widget found!") log.Log(GOCUI, "stdout widget found!")
tk.dumpWidget("stdout click") 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: default:
tk.dumpWidget("blank click()") tk.dumpWidget("blank click()")
} }
@ -100,6 +101,14 @@ func click(g *gocui.Gui, v *gocui.View) error {
w := mouseW w := mouseW
h := mouseH 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) { for _, tk := range findByXY(w, h) {
// will show you everything found on a mouse click. great for debugging! // will show you everything found on a mouse click. great for debugging!
// tk.dumpWidget("click()") // tk.dumpWidget("click()")

View File

@ -24,7 +24,7 @@ import (
var helpText []string = []string{"KEYBINDINGS", var helpText []string = []string{"KEYBINDINGS",
"", "",
"?: toggle zhelp", "?: toggle help",
"S: super mouse", "S: super mouse",
"M: list all widgets positions", "M: list all widgets positions",
"L: list all widgets in tree form", "L: list all widgets in tree form",

View File

@ -160,8 +160,9 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
return len(p), nil return len(p), nil
} }
// this sets the `default` in the structs // THIS IS GO COMPILER MAGIC
// this is cool code. thank Alex Flint & other GO devs for this code // 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 { func Set(ptr interface{}, tag string) error {
if reflect.TypeOf(ptr).Kind() != reflect.Ptr { if reflect.TypeOf(ptr).Kind() != reflect.Ptr {
log.Log(ERROR, "Set() Not a pointer", ptr, "with tag =", tag) log.Log(ERROR, "Set() Not a pointer", ptr, "with tag =", tag)