summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-08 10:00:12 -0600
committerJeff Carr <[email protected]>2025-02-08 10:00:12 -0600
commit227419c1ad5d79873be01e4dee3d10f367e400d6 (patch)
tree0911f538fe5b1a5ce1765db7965259d8b6beaa83
parent7b06b81ed3b4e54a5eabd581ecf5144a04074514 (diff)
dropdown menu works again
-rw-r--r--dropdown.go3
-rw-r--r--eventMouseClick.go38
2 files changed, 29 insertions, 12 deletions
diff --git a/dropdown.go b/dropdown.go
index 407d626..b340168 100644
--- a/dropdown.go
+++ b/dropdown.go
@@ -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 {
diff --git a/eventMouseClick.go b/eventMouseClick.go
index 92839a6..c884ea5 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -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 {