diff options
Diffstat (limited to 'eventMouseClick.go')
| -rw-r--r-- | eventMouseClick.go | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/eventMouseClick.go b/eventMouseClick.go index dcda9fd..88e37a3 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -130,37 +130,47 @@ func doMouseClick(w int, h int) { return } - // priority widgets. send the click here first - for _, tk := range findByXY(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() + 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.dumpWidget("click()") // enable this to debug widget clicks + 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: + // TODO: enable the GUI debugger in gocui + // tk.dumpWidget("undef click()") // enable this to debug widget clicks } - me.myTree.SendUserEvent(tk.node) - case widget.Button: - tk.dumpWidget("click()") // enable this to debug widget clicks - 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: - // 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", win.cuiName) + win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0) + me.stdout.outputOnTop = false + setThingsOnTop() + return } var found bool |
