diff options
| author | Jeff Carr <[email protected]> | 2025-02-02 23:36:33 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-02 23:36:33 -0600 |
| commit | a5b3a934d2a2355ce2487f5b3ce52dff2f8a9047 (patch) | |
| tree | 0ba579ff5665f5906f72ce965ce593df6e581edb /eventMouseMove.go | |
| parent | 517d844b3c8257dd796244e6a151deceabedab42 (diff) | |
finally can drag something else
Diffstat (limited to 'eventMouseMove.go')
| -rw-r--r-- | eventMouseMove.go | 28 |
1 files changed, 24 insertions, 4 deletions
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 |
