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()
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")

View File

@ -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()")

View File

@ -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",

View File

@ -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)