summaryrefslogtreecommitdiff
path: root/eventMouseClick.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-09 12:34:53 -0600
committerJeff Carr <[email protected]>2025-02-09 12:34:53 -0600
commit90a9f84f109800b820f5d15bad0b7ba146586edc (patch)
tree6e684cf463bad756e9631e514e5b46b13982b3b7 /eventMouseClick.go
parentc5cada3dc93ba0f049b50fd7561a2c15347473ee (diff)
more code cleanups
Diffstat (limited to 'eventMouseClick.go')
-rw-r--r--eventMouseClick.go83
1 files changed, 46 insertions, 37 deletions
diff --git a/eventMouseClick.go b/eventMouseClick.go
index 79809b0..54547af 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -77,48 +77,57 @@ func doMouseClick(w int, h int) {
}
win := findWindowUnderMouse()
- if win != nil {
- // look in this window for widgets
- // widgets have priority. send the click here first
- for _, tk := range win.findByXYreal(w, h) {
- switch tk.node.WidgetType {
- case widget.Checkbox:
- if tk.node.State.Checked {
- log.Log(WARN, "checkbox is being set to false")
- tk.node.State.Checked = false
- tk.setCheckbox()
- } else {
- log.Log(WARN, "checkbox is being set to true")
- tk.node.State.Checked = true
- tk.setCheckbox()
- }
- me.myTree.SendUserEvent(tk.node)
- return
- case widget.Button:
- tk.doButtonClick()
- return
- case widget.Combobox:
- tk.showDropdown()
- return
- case widget.Dropdown:
- tk.showDropdown()
- return
- case widget.Textbox:
- tk.showTextbox()
- return
- default:
- // TODO: enable the GUI debugger in gocui
- // tk.dumpWidget("undef click()") // enable this to debug widget clicks
- }
- }
+ if win == nil {
+ log.Log(GOCUI, "click() nothing was at:", w, h)
+ return
+ }
+ if !win.isWindowActive() {
+ win.makeWindowActive()
+ return
+ } else {
+ // potentally the user is closing the window
if win.checkWindowClose(w, h) {
return
}
- // log.Info("you clicked on a window, but not any widgets. check for title / close window here", win.cuiName)
- win.makeWindowActive()
- return
}
+ // look in this window for widgets
+ // widgets have priority. send the click here first
+ for _, tk := range win.findByXYreal(w, h) {
+ switch tk.node.WidgetType {
+ case widget.Checkbox:
+ if tk.node.State.Checked {
+ log.Log(WARN, "checkbox is being set to false")
+ tk.node.State.Checked = false
+ tk.setCheckbox()
+ } else {
+ log.Log(WARN, "checkbox is being set to true")
+ tk.node.State.Checked = true
+ tk.setCheckbox()
+ }
+ me.myTree.SendUserEvent(tk.node)
+ return
+ case widget.Button:
+ tk.doButtonClick()
+ return
+ case widget.Combobox:
+ tk.showDropdown()
+ return
+ case widget.Dropdown:
+ tk.showDropdown()
+ return
+ case widget.Textbox:
+ tk.showTextbox()
+ return
+ default:
+ // TODO: enable the GUI debugger in gocui
+ // tk.dumpWidget("undef click()") // enable this to debug widget clicks
+ }
+ }
+ // log.Info("you clicked on a window, but not any widgets. check for title / close window here", win.cuiName)
+ // win.makeWindowActive()
+ // return
+
var found bool
for _, tk := range findByXY(w, h) {