mouse double click implemented too. why not? took 5 minutes
This commit is contained in:
parent
078a23e0e0
commit
1010db44a6
|
@ -24,6 +24,13 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
me.mouse.globalMouseDown = false
|
me.mouse.globalMouseDown = false
|
||||||
me.mouse.currentDrag = nil
|
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 {
|
if time.Since(me.mouse.down) < me.mouse.clicktime {
|
||||||
doMouseClick(me.mouse.downW, me.mouse.downH)
|
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 {
|
func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
if me.mouse.mouseUp {
|
if me.mouse.mouseUp {
|
||||||
if time.Since(me.mouse.down) < me.mouse.doubletime {
|
if time.Since(me.mouse.down) < me.mouse.doubletime {
|
||||||
log.Info("double click")
|
me.mouse.double = true
|
||||||
}
|
}
|
||||||
me.mouse.globalMouseDown = true
|
me.mouse.globalMouseDown = true
|
||||||
me.mouse.mouseUp = false
|
me.mouse.mouseUp = false
|
||||||
|
|
|
@ -142,3 +142,8 @@ func doMouseClick(w int, h int) {
|
||||||
log.Log(GOCUI, "click() nothing was at:", w, h)
|
log.Log(GOCUI, "click() nothing was at:", w, h)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doMouseDoubleClick(w int, h int) {
|
||||||
|
me.mouse.double = false
|
||||||
|
log.Printf("actually a double click (%d,%d)", w, h)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue