diff options
Diffstat (limited to 'eventMouseClick.go')
| -rw-r--r-- | eventMouseClick.go | 83 |
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) { |
