diff --git a/eventMouse.go b/eventMouse.go index 8d88b01..6512805 100644 --- a/eventMouse.go +++ b/eventMouse.go @@ -66,8 +66,10 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { } for _, tk := range findByXY(mx, my) { if tk.node.WidgetType == widget.Window { - log.Info("SENDING CLICK TO WINDOW") - tk.doWidgetClick(mx, my) + tk.dragW = mx - tk.gocuiSize.w0 + tk.dragH = my - tk.gocuiSize.h0 + 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 { diff --git a/eventMouseMove.go b/eventMouseMove.go index 0bfec5b..e7c8b46 100644 --- a/eventMouseMove.go +++ b/eventMouseMove.go @@ -93,7 +93,7 @@ func (tk *guiWidget) moveNew() { w, h := me.baseGui.MousePosition() if tk.node.WidgetType == widget.Window { tk.DrawAt(w, h) - tk.redrawWindow(w-2, h-2) // TODO: fix these hard coded things with offsets + tk.redrawWindow(w-tk.dragW, h-tk.dragH) // TODO: fix these hard coded things with offsets // tk.dumpWidget(fmt.Sprintf("move(%dx%d) %s WIN", w, h, tk.cuiName)) return } diff --git a/structs.go b/structs.go index ce06d02..3fde7ef 100644 --- a/structs.go +++ b/structs.go @@ -101,6 +101,8 @@ type guiWidget struct { node *tree.Node // the pointer back to the tree windowFrame *guiWidget // this is the frame for a window widget internal bool // indicates the widget is internal to gocui and should be treated differently + dragW int // when dragging a window, this is the offset to the mouse position + dragH int // when dragging a window, this is the offset to the mouse position hasTabs bool // does the window have tabs? currentTab bool // the visible tab value string // ?