diff options
Diffstat (limited to 'eventMouse.go')
| -rw-r--r-- | eventMouse.go | 111 |
1 files changed, 41 insertions, 70 deletions
diff --git a/eventMouse.go b/eventMouse.go index 1757ed0..c8d3fca 100644 --- a/eventMouse.go +++ b/eventMouse.go @@ -4,8 +4,6 @@ package main import ( - "fmt" - "github.com/awesome-gocui/gocui" "go.wit.com/log" @@ -24,7 +22,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error { log.Info("mouseUp() setting me.globalMouseDown = false") me.globalMouseDown = false - currentDrag = nil + me.currentDrag = nil dropdownUnclicked(w, h) @@ -38,8 +36,12 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { log.Info("mouseDown() setting globalMouseDown = true") me.globalMouseDown = true + w, h := g.MousePosition() + me.downW = w + me.downH = h + + // if the dropdown is active, never do anything else if me.dropdown.active { - w, h := g.MousePosition() log.Info("mouseDown() stopping here. dropdwon menu is in effect") for _, tk := range findByXY(w, h) { if (tk.node.WidgetType == widget.Flag) && (tk == me.dropdown.tk) { @@ -54,79 +56,48 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { return nil } - var found bool = false - w, h := g.MousePosition() - for _, tk := range findByXY(w, h) { - tk.dumpWidget("mouseDown()") - if tk.node.WidgetType == widget.Button { - log.Info("SENDING CLICK TO Button") - tk.doWidgetClick(w, h) - return nil - } - if tk.node.WidgetType == widget.Checkbox { - log.Info("SENDING CLICK TO Checkbox") - tk.doWidgetClick(w, h) - return nil - } - if tk.node.WidgetType == widget.Dropdown { - log.Info("SENDING CLICK TO Dropdown") - tk.doWidgetClick(w, h) - return nil - } - if tk.node.WidgetType == widget.Textbox { - log.Info("SENDING CLICK TO Textbox") - tk.doWidgetClick(w, h) - return nil - } - found = true - } - if tk := findWindowUnderMouse(); tk != nil { - w, h := g.MousePosition() - tk.dragW = w - tk.gocuiSize.w0 - tk.dragH = h - tk.gocuiSize.h0 - tk.doWidgetClick(w-tk.dragW, w-tk.dragH) + // figre out what window this is + tk := findWindowUnderMouse() + if tk == nil { + log.Info("mouseDown() nothing to click on at", w, h) + return nil } - - mx, my := g.MousePosition() - for _, tk := range findByXY(mx, my) { - if tk.node.WidgetType == widget.Window { - tk.dragW = mx - tk.gocuiSize.w0 - tk.dragH = my - tk.gocuiSize.h0 - if (mx-tk.gocuiSize.w0 < 3) && (my-tk.gocuiSize.h0 < 3) { - log.Info("RESIZE WINDOW", tk.dragW, tk.dragH) + log.Info("SENDING mouseDown() to findWindowUnderMouse()") + if tk.node.WidgetType == widget.Window { + // check to see if this is a direct click on a widget + for _, tk := range tk.findByXYreal(w, h) { + tk.dumpWidget("mouseDown()") + if tk.node.WidgetType == widget.Button { + log.Info("SENDING CLICK TO Button") + tk.doWidgetClick(w, h) + return nil } - log.Info("SENDING CLICK TO WINDOW", tk.dragW, tk.dragH) - tk.doWidgetClick(mx-tk.dragW, my-tk.dragH) - return nil - } - if tk.node.WidgetType == widget.Label { - log.Info("IGNORE LABLE") - found = false - log.Info("setting mousedown to true for label") - // msgMouseDown = true - return nil - } - /* - if tk.node.WidgetType == widget.Label { - log.Info("SENDING CLICK TO Label") - tk.doWidgetClick(mx, my) + if tk.node.WidgetType == widget.Checkbox { + log.Info("SENDING CLICK TO Checkbox") + tk.doWidgetClick(w, h) + return nil + } + if tk.node.WidgetType == widget.Dropdown { + log.Info("SENDING CLICK TO Dropdown") + tk.doWidgetClick(w, h) + return nil + } + if tk.node.WidgetType == widget.Textbox { + log.Info("SENDING CLICK TO Textbox") + tk.doWidgetClick(w, h) return nil } - */ - found = true - } - if !found { - log.Log(GOCUI, fmt.Sprintf("mouseDown() found nothing at (%d,%d)", mx, my)) - } - - // sort this junk out - vx0, vy0, vx1, vy1, err := g.ViewPosition("msg") - if err == nil { - if mx >= vx0 && mx <= vx1 && my >= vy0 && my <= vy1 { - return msgDown(g, v) } } + me.currentDrag = tk + tk.dragW = w - tk.gocuiSize.w0 + tk.dragH = h - tk.gocuiSize.h0 + tk.doWidgetClick(w-tk.dragW, w-tk.dragH) return nil + + // move the msg I guess + // return msgDown(g, v) + // return nil } // this needs to go |
