From 15dbf37154372c4aa15fbda1b6319fb81109209d Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Fri, 22 Apr 2016 09:11:44 -0400 Subject: [PATCH 1/2] Possible fix for elementary mouse issue --- cmd/micro/view.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 939b5e91..35264beb 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -528,7 +528,7 @@ func (v *View) HandleEvent(event tcell.Event) { origX, origY := v.cursor.x, v.cursor.y v.MoveToMouseClick(x, y) - if v.mouseReleased { + if v.mouseReleased && !e.HasMotion() { if (time.Since(v.lastClickTime)/time.Millisecond < doubleClickThreshold) && (origX == v.cursor.x && origY == v.cursor.y) { if v.doubleClick { @@ -557,6 +557,7 @@ func (v *View) HandleEvent(event tcell.Event) { v.cursor.curSelection[0] = loc v.cursor.curSelection[1] = loc } + v.mouseReleased = false } else { if v.tripleClick { v.cursor.AddLineToSelection() @@ -566,7 +567,6 @@ func (v *View) HandleEvent(event tcell.Event) { v.cursor.curSelection[1] = v.cursor.Loc() } } - v.mouseReleased = false case tcell.ButtonNone: // Mouse event with no click if !v.mouseReleased { From 3d76898afef39b128789a80165c25e24f4576367 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Fri, 22 Apr 2016 19:12:32 -0400 Subject: [PATCH 2/2] Fix elementary mouse issue Fixes #34 This commit requires a modification to tcell before it will work. --- cmd/micro/view.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 35264beb..b6707bef 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -526,9 +526,9 @@ func (v *View) HandleEvent(event tcell.Event) { case tcell.Button1: // Left click origX, origY := v.cursor.x, v.cursor.y - v.MoveToMouseClick(x, y) if v.mouseReleased && !e.HasMotion() { + v.MoveToMouseClick(x, y) if (time.Since(v.lastClickTime)/time.Millisecond < doubleClickThreshold) && (origX == v.cursor.x && origY == v.cursor.y) { if v.doubleClick { @@ -558,7 +558,8 @@ func (v *View) HandleEvent(event tcell.Event) { v.cursor.curSelection[1] = loc } v.mouseReleased = false - } else { + } else if !v.mouseReleased { + v.MoveToMouseClick(x, y) if v.tripleClick { v.cursor.AddLineToSelection() } else if v.doubleClick {