From 9eef8dfb9e4b212b5ca1dd5757ad8eb1b31bec37 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Wed, 2 Oct 2013 02:52:49 +1000 Subject: [PATCH] Fix issue with blinking cursor on drag over This happens when dragging from another app. Editor can get focused on app icon hovering (on a Windows taskbar). --- lib/ace/mouse/dragdrop_handler.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ace/mouse/dragdrop_handler.js b/lib/ace/mouse/dragdrop_handler.js index 887a6701..722dcb6a 100644 --- a/lib/ace/mouse/dragdrop_handler.js +++ b/lib/ace/mouse/dragdrop_handler.js @@ -62,6 +62,7 @@ function DragdropHandler(mouseHandler) { var timerId, range; var dragCursor, counter = 0; var dragOperation; + var isInternal; var autoScrollStartTime; var cursorMovedTime; var cursorPointOnCaretMoved; @@ -93,11 +94,13 @@ function DragdropHandler(mouseHandler) { dataTransfer.clearData(); dataTransfer.setData("Text", editor.session.getTextRange()); + isInternal = true; this.setState("drag"); }; this.onDragEnd = function(e) { mouseTarget.draggable = false; + isInternal = false; this.setState(null); if (!editor.getReadOnly()) { var dropEffect = e.dataTransfer.dropEffect; @@ -150,7 +153,6 @@ function DragdropHandler(mouseHandler) { if (!dragSelectionMarker) return; var dataTransfer = e.dataTransfer; - var isInternal = this.state == "drag"; if (isInternal) { switch (dragOperation) { case "move": @@ -259,6 +261,8 @@ function DragdropHandler(mouseHandler) { range = editor.selection.toOrientedRange(); dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle()); editor.clearSelection(); + if (editor.isFocused()) + editor.renderer.$cursorLayer.setBlinking(false); clearInterval(timerId); timerId = setInterval(onDragInterval, 20); counter = 0; @@ -272,6 +276,8 @@ function DragdropHandler(mouseHandler) { editor.$blockScrolling += 1; editor.selection.fromOrientedRange(range); editor.$blockScrolling -= 1; + if (editor.isFocused() && !isInternal) + editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly()); range = null; counter = 0; autoScrollStartTime = null;