From a5b3a934d2a2355ce2487f5b3ce52dff2f8a9047 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 2 Feb 2025 23:36:33 -0600 Subject: finally can drag something else --- eventMouseMove.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'eventMouseMove.go') diff --git a/eventMouseMove.go b/eventMouseMove.go index 97c574a..51835cb 100644 --- a/eventMouseMove.go +++ b/eventMouseMove.go @@ -19,6 +19,8 @@ import ( "go.wit.com/widget" ) +var currentDrag *guiWidget + // this function uses the mouse position to highlight & unhighlight things // this is run every time the user moves the mouse over the terminal window func mouseMove(g *gocui.Gui) { @@ -38,13 +40,26 @@ func mouseMove(g *gocui.Gui) { // plugin will segfault if you don't keep this inside a check for msgMouseDown // don't move this code out of here var found bool = false + if currentDrag != nil { + currentDrag.moveNew(g) + return + } + for _, tk := range findByXY(w, h) { + if tk.node.WidgetType == widget.Flag { + currentDrag = tk + // tk.moveNew(g) + return + } + } for _, tk := range findByXY(w, h) { if tk.node.WidgetType == widget.Stdout { - tk.moveNew(g) + // currentDrag = tk + // tk.moveNew(g) return } if tk.node.WidgetType == widget.Label { - tk.moveNew(g) + currentDrag = tk + // tk.moveNew(g) return } found = true @@ -72,15 +87,20 @@ func mouseMove(g *gocui.Gui) { // this is how the window gets dragged around func (tk *guiWidget) moveNew(g *gocui.Gui) { w, h := g.MousePosition() - if tk.node.WidgetType == widget.Label { + if tk.node.WidgetType == widget.Flag { + log.Info("MOVE FLAG") + log.Info("MOVE FLAG") s := fmt.Sprintf("move(%dx%d) %s ###", w, h, tk.cuiName) tk.dumpWidget(s) outputW, outputH := tk.Size() - g.SetView(tk.cuiName, w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0) + g.SetView(tk.cuiName, w-xOffset, h-yOffset, w-xOffset+outputW+20, h-yOffset+outputH+me.FramePadH+20, 0) me.startOutputW = w - xOffset me.startOutputH = h - yOffset // g.SetViewOnBottom(tk.cuiName) return + } else { + log.Info("NOT MOVE FLAG", tk.node.WidgetType) + log.Info("NOT MOVE FLAG", tk.node.WidgetType) } tk.dumpWidget("moveNew() on " + tk.cuiName) outputW := 140 -- cgit v1.2.3