diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 0bca7288..127ff164 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -271,6 +271,10 @@ var Editor =function(renderer, session) { } this.textInput.focus(); }; + + this.isFocused = function() { + return this.textInput.isFocused(); + }; this.blur = function() { this.textInput.blur(); diff --git a/lib/ace/mouse_handler.js b/lib/ace/mouse_handler.js index 910a4ec0..2f7b30a7 100644 --- a/lib/ace/mouse_handler.js +++ b/lib/ace/mouse_handler.js @@ -41,6 +41,7 @@ define(function(require, exports, module) { var event = require("pilot/event"); var dom = require("pilot/dom"); +var BrowserFocus = require("pilot/browser_focus").BrowserFocus; var STATE_UNKNOWN = 0; var STATE_SELECT = 1; @@ -51,6 +52,8 @@ var DRAG_OFFSET = 5; // pixels var MouseHandler = function(editor) { this.editor = editor; + + this.browserFocus = new BrowserFocus(); event.addListener(editor.container, "mousedown", function(e) { editor.focus(); return event.preventDefault(e); @@ -91,6 +94,15 @@ var MouseHandler = function(editor) { }; this.onMouseDown = function(e) { + // if this click caused the editor to be focused ignore the click + // for selection and cursor placement + if ( + !this.browserFocus.isFocused() + || new Date().getTime() - this.browserFocus.lastFocus < 20 + || !this.editor.isFocused() + ) + return; + var pageX = event.getDocumentX(e); var pageY = event.getDocumentY(e); var pos = this.$getEventPosition(e); diff --git a/support/pilot b/support/pilot index e89a461e..fb3c117f 160000 --- a/support/pilot +++ b/support/pilot @@ -1 +1 @@ -Subproject commit e89a461ee76ae49e9fc1653dd28ad2064e18f51f +Subproject commit fb3c117f12a55432a5f5e3d056b877217ec32202