dropdown menu works again

This commit is contained in:
Jeff Carr 2025-02-08 10:00:12 -06:00
parent 7b06b81ed3
commit 227419c1ad
2 changed files with 29 additions and 12 deletions

View File

@ -80,6 +80,7 @@ func (tk *guiWidget) showDropdown() {
// if there is a drop down view active, treat it like a dialog box and close it
func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
w.Hide()
me.dropdown.active = false
// only need height to figure out what line in the dropdown menu the user clicked
_, startH := w.Position()
@ -106,6 +107,7 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
return ""
}
/*
func dropdownUnclicked(w, h int) {
var d *guiWidget
@ -122,6 +124,7 @@ func dropdownUnclicked(w, h int) {
}
// log.Log(GOCUI, "dropdownUnclicked()", d.node.Strings(), "end. now try to enable me.dropdownV")
}
*/
func (tk *guiWidget) showTextbox() {
if me.textbox.tk == nil {

View File

@ -110,23 +110,37 @@ func (tk *guiWidget) doWidgetClick(w int, h int) {
// handles a mouse click
func doMouseClick(w int, h int) {
dropdownUnclicked(w, h)
/*
// Flag widgets (dropdown menus, etc) are the highest priority. ALWAYS SEND MOUSE CLICKS THERE FIRST
// Flag widgets (dropdown menus, etc) are the highest priority. ALWAYS SEND MOUSE CLICKS THERE FIRST
// handle an open dropdown menu or text entry window first
if me.dropdown.active || me.textbox.active {
// 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) {
if tk.node.WidgetType == widget.Flag {
tk.doWidgetClick(w, h)
return
if tk.node.WidgetId == me.dropdown.wId {
log.Info("got dropdwon click", w, h, tk.cuiName)
tk.dropdownClicked(w, h)
}
}
*/
return
}
// Button widgets
// priority widgets. send the click here first
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Button {
tk.doWidgetClick(w, h)
switch tk.node.WidgetType {
case widget.Button:
me.myTree.SendFromUser(tk.node)
return
case widget.Combobox:
tk.showDropdown()
return
case widget.Dropdown:
tk.showDropdown()
return
case widget.Textbox:
tk.showTextbox()
return
default:
tk.dumpWidget("undef click()")
}
}
@ -153,7 +167,7 @@ func doMouseClick(w int, h int) {
func doMouseDoubleClick(w int, h int) {
me.mouse.double = false
log.Printf("actually a double click (%d,%d)", w, h)
// log.Printf("actually a double click (%d,%d)", w, h)
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Window {