dropdown works again

This commit is contained in:
Jeff Carr 2025-02-08 15:01:36 -06:00
parent ea544e429e
commit 42eafb87c7
4 changed files with 42 additions and 8 deletions

View File

@ -142,3 +142,22 @@ func (tk *guiWidget) setColorInput() {
tk.color.selFg = gocui.ColorYellow tk.color.selFg = gocui.ColorYellow
tk.color.selBg = gocui.ColorBlack tk.color.selBg = gocui.ColorBlack
} }
func (tk *guiWidget) setColorModal() {
if tk.color == nil {
tk.color = new(colorT)
}
if me.dark {
tk.color.frame = gocui.ColorRed
tk.color.fg = gocui.ColorRed
tk.color.bg = gocui.ColorBlack
tk.color.selFg = gocui.ColorBlack
tk.color.selBg = gocui.AttrNone
return
}
tk.color.frame = gocui.ColorRed
tk.color.fg = gocui.AttrNone
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.AttrNone
tk.color.selBg = gocui.ColorRed
}

View File

@ -85,14 +85,12 @@ func (tk *guiWidget) dumpWidget(s string) {
if tk.node.WidgetType == widget.Box { if tk.node.WidgetType == widget.Box {
end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, tk.node.State.Direction.String()) end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, tk.node.State.Direction.String())
} else { } else {
curval := tk.String() curval := strings.TrimSpace(tk.node.ProgName())
if curval == "" { if curval == "" {
curval = tk.node.GetLabel() curval = strings.TrimSpace(tk.node.GetLabel())
curval = strings.TrimSpace(curval)
} }
if curval == "" { if curval == "" {
curval = tk.labelN curval = strings.TrimSpace(tk.labelN)
curval = strings.TrimSpace(curval)
} }
end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, curval) end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, curval)
} }

View File

@ -74,6 +74,13 @@ func (tk *guiWidget) showDropdown() {
me.dropdown.tk.Show() me.dropdown.tk.Show()
me.dropdown.active = true me.dropdown.active = true
me.dropdown.callerTK = tk me.dropdown.callerTK = tk
r := me.dropdown.tk.gocuiSize // set the 'full' size so that mouse clicks are sent here
me.dropdown.tk.full.w0 = r.w0
me.dropdown.tk.full.w1 = r.w1
me.dropdown.tk.full.h0 = r.h0
me.dropdown.tk.full.h1 = r.h1
me.dropdown.tk.dumpWidget("showDropdown()") me.dropdown.tk.dumpWidget("showDropdown()")
} }
@ -140,15 +147,17 @@ func (tk *guiWidget) showTextbox() {
// log.Log(GOCUI, "showTextbox() SHOWING AT W,H=", startW, startH) // log.Log(GOCUI, "showTextbox() SHOWING AT W,H=", startW, startH)
me.textbox.tk.MoveToOffset(startW+3, startH+2) me.textbox.tk.MoveToOffset(startW+3, startH+2)
me.textbox.tk.labelN = "holy cow" me.textbox.tk.labelN = "holy cow"
me.textbox.tk.setColorInput() me.textbox.tk.setColorModal()
me.textbox.tk.Show() me.textbox.tk.Show()
me.textbox.active = true me.textbox.active = true
me.textbox.callerTK = tk me.textbox.callerTK = tk
r := me.textbox.tk.gocuiSize
r := me.textbox.tk.gocuiSize // set the 'full' size so that mouse clicks are sent here
me.textbox.tk.full.w0 = r.w0 me.textbox.tk.full.w0 = r.w0
me.textbox.tk.full.w1 = r.w1 me.textbox.tk.full.w1 = r.w1
me.textbox.tk.full.h0 = r.h0 me.textbox.tk.full.h0 = r.h0
me.textbox.tk.full.h1 = r.h1 me.textbox.tk.full.h1 = r.h1
me.textbox.tk.dumpWidget("showTextbox()") me.textbox.tk.dumpWidget("showTextbox()")
} }

View File

@ -114,17 +114,19 @@ func doMouseClick(w int, h int) {
// handle an open dropdown menu or text entry window first // handle an open dropdown menu or text entry window first
if me.dropdown.active || me.textbox.active { if me.dropdown.active || me.textbox.active {
// can't drag or do anything when dropdown or textbox are visible // can't drag or do anything when dropdown or textbox are visible
log.Info("can't do anything. dropdown or textbox is active")
for _, tk := range findByXY(w, h) { for _, tk := range findByXY(w, h) {
if tk.node.WidgetId == me.dropdown.wId { if tk.node.WidgetId == me.dropdown.wId {
log.Info("got dropdwon click", w, h, tk.cuiName) log.Info("got dropdwon click", w, h, tk.cuiName)
tk.dropdownClicked(w, h) tk.dropdownClicked(w, h)
return
} }
if tk.node.WidgetId == me.textbox.wId { if tk.node.WidgetId == me.textbox.wId {
log.Info("got textbox click", w, h, tk.cuiName) log.Info("got textbox click", w, h, tk.cuiName)
tk.textboxClosed() tk.textboxClosed()
return
} }
} }
log.Info("a dropdown or textbox is active. you can't click anywhere else (otherwise hit ESC)", w, h)
return return
} }
@ -186,6 +188,12 @@ func doMouseDoubleClick(w int, h int) {
me.mouse.double = false me.mouse.double = false
// log.Printf("actually a double click (%d,%d)", w, h) // log.Printf("actually a double click (%d,%d)", w, h)
if me.dropdown.active || me.textbox.active {
// can't drag or do anything when dropdown or textbox are visible
log.Info("can't double click. dropdown or textbox is active")
return
}
for _, tk := range findByXY(w, h) { for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Window { if tk.node.WidgetType == widget.Window {
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0) tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)