mouse double click implemented too. why not? took 5 minutes

This commit is contained in:
Jeff Carr 2025-02-08 08:42:41 -06:00
parent 078a23e0e0
commit 1010db44a6
2 changed files with 13 additions and 1 deletions

View File

@ -24,6 +24,13 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
me.mouse.globalMouseDown = false
me.mouse.currentDrag = nil
if me.mouse.double && (time.Since(me.mouse.down) < me.mouse.doubletime) {
me.mouse.double = false
doMouseDoubleClick(me.mouse.downW, me.mouse.downH)
return nil
}
me.mouse.double = false
if time.Since(me.mouse.down) < me.mouse.clicktime {
doMouseClick(me.mouse.downW, me.mouse.downH)
}
@ -36,7 +43,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
func mouseDown(g *gocui.Gui, v *gocui.View) error {
if me.mouse.mouseUp {
if time.Since(me.mouse.down) < me.mouse.doubletime {
log.Info("double click")
me.mouse.double = true
}
me.mouse.globalMouseDown = true
me.mouse.mouseUp = false

View File

@ -142,3 +142,8 @@ func doMouseClick(w int, h int) {
log.Log(GOCUI, "click() nothing was at:", w, h)
return
}
func doMouseDoubleClick(w int, h int) {
me.mouse.double = false
log.Printf("actually a double click (%d,%d)", w, h)
}