when a click causes the editor to be focused ignore

it. fix #168
This commit is contained in:
Fabian Jakobs 2011-07-22 13:06:45 +02:00
commit 4dfe33655e
3 changed files with 17 additions and 1 deletions

View file

@ -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();

View file

@ -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);

@ -1 +1 @@
Subproject commit e89a461ee76ae49e9fc1653dd28ad2064e18f51f
Subproject commit fb3c117f12a55432a5f5e3d056b877217ec32202