only ignore focus click if it is inside of the selection
This commit is contained in:
parent
5d83b20903
commit
63a6f19386
1 changed files with 20 additions and 16 deletions
|
|
@ -94,24 +94,33 @@ var MouseHandler = function(editor) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onMouseDown = function(e) {
|
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 pageX = event.getDocumentX(e);
|
||||||
var pageY = event.getDocumentY(e);
|
var pageY = event.getDocumentY(e);
|
||||||
|
|
||||||
var pos = this.$getEventPosition(e);
|
var pos = this.$getEventPosition(e);
|
||||||
|
|
||||||
var editor = this.editor;
|
var editor = this.editor;
|
||||||
var self = this;
|
var self = this;
|
||||||
var selectionRange = editor.getSelectionRange();
|
var selectionRange = editor.getSelectionRange();
|
||||||
var selectionEmpty = selectionRange.isEmpty();
|
var selectionEmpty = selectionRange.isEmpty();
|
||||||
|
var inSelection = !editor.getReadOnly()
|
||||||
|
&& !selectionEmpty
|
||||||
|
&& selectionRange.contains(pos.row, pos.column);
|
||||||
|
|
||||||
var state = STATE_UNKNOWN;
|
var state = STATE_UNKNOWN;
|
||||||
var inSelection = false;
|
|
||||||
|
// if this click caused the editor to be focused should not clear the
|
||||||
|
// selection
|
||||||
|
if (
|
||||||
|
inSelection && (
|
||||||
|
!this.browserFocus.isFocused()
|
||||||
|
|| new Date().getTime() - this.browserFocus.lastFocus < 20
|
||||||
|
|| !this.editor.isFocused()
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.editor.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var button = event.getButton(e);
|
var button = event.getButton(e);
|
||||||
if (button !== 0) {
|
if (button !== 0) {
|
||||||
|
|
@ -130,10 +139,6 @@ var MouseHandler = function(editor) {
|
||||||
editor.selection.setSelectionRange(fold.range);
|
editor.selection.setSelectionRange(fold.range);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inSelection = !editor.getReadOnly()
|
|
||||||
&& !selectionEmpty
|
|
||||||
&& selectionRange.contains(pos.row, pos.column);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inSelection) {
|
if (!inSelection) {
|
||||||
|
|
@ -261,8 +266,7 @@ var MouseHandler = function(editor) {
|
||||||
|
|
||||||
var onDragSelectionInterval = function() {
|
var onDragSelectionInterval = function() {
|
||||||
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||||
dragCursor.row = Math.max(0, Math.min(dragCursor.row,
|
dragCursor.row = Math.max(0, Math.min(dragCursor.row, editor.session.getLength() - 1));
|
||||||
editor.session.getLength() - 1));
|
|
||||||
|
|
||||||
editor.moveCursorToPosition(dragCursor);
|
editor.moveCursorToPosition(dragCursor);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue