diff options
| author | Jeff Carr <[email protected]> | 2025-01-31 08:50:00 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-31 13:47:45 -0600 |
| commit | 75a5c7bf728d02bcf5accd1360c99a9c6edc0b91 (patch) | |
| tree | d0c783cbeaedb2c1188951fd95fc04d1fd55d54c /mouse.go | |
| parent | 11465e4043304d40a815c49adc3d829e5ba55449 (diff) | |
wrapping my head around this code again
Diffstat (limited to 'mouse.go')
| -rw-r--r-- | mouse.go | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -2,6 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// note by [email protected] in 2025: this is one of the coolest +// things ever what this does. I've tried to improve +// it while I've been working on making a gocui +// GO plugin so it can be generalized as a useful +// console interface. Well done everyone that has +// contributed to this gocui project !!! + package main import ( @@ -27,8 +34,13 @@ func mouseMove(g *gocui.Gui) { func msgDown(g *gocui.Gui, v *gocui.View) error { initialMouseX, initialMouseY = g.MousePosition() + + // debugging output log.Log(GOCUI, "msgDown() X,Y", initialMouseX, initialMouseY) - if vx, vy, _, _, err := g.ViewPosition("msg"); err == nil { + + // + vx, vy, _, _, err := g.ViewPosition("msg") + if err == nil { xOffset = initialMouseX - vx yOffset = initialMouseY - vy msgMouseDown = true @@ -40,6 +52,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error { w, h := g.MousePosition() dropdownUnclicked(w, h) + if msgMouseDown { msgMouseDown = false if movingMsg { @@ -55,16 +68,26 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error { return nil } +// func isMouseInMsg + +// this is where you have to figure out what +// widget was underneath so you can active +// the right response for the toolkit user's app func mouseDown(g *gocui.Gui, v *gocui.View) error { mx, my := g.MousePosition() - if vx0, vy0, vx1, vy1, err := g.ViewPosition("msg"); err == nil { + + vx0, vy0, vx1, vy1, err := g.ViewPosition("msg") + if err == nil { if mx >= vx0 && mx <= vx1 && my >= vy0 && my <= vy1 { return msgDown(g, v) } } globalMouseDown = true + maxX, _ := g.Size() + findUnderMouse() + msg := fmt.Sprintf("mouseDown() Mouse really down at: %d,%d", mx, my) // dropdownClicked(mx, my) x := mx - len(msg)/2 |
