fix triple click

This commit is contained in:
Fabian Jakobs 2011-02-20 13:18:27 +01:00
commit 387e282029

View file

@ -94,6 +94,7 @@ var MouseHandler = function(editor) {
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 selectionRange = editor.getSelectionRange(); var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty(); var selectionEmpty = selectionRange.isEmpty();
var state = STATE_UNKNOWN; var state = STATE_UNKNOWN;
@ -122,7 +123,6 @@ var MouseHandler = function(editor) {
editor.renderer.scrollCursorIntoView(); editor.renderer.scrollCursorIntoView();
var self = this;
var mousePageX, mousePageY; var mousePageX, mousePageY;
var overwrite = editor.getOverwrite(); var overwrite = editor.getOverwrite();
var dragCursor = null; var dragCursor = null;
@ -135,13 +135,12 @@ var MouseHandler = function(editor) {
var onMouseSelectionEnd = function() { var onMouseSelectionEnd = function() {
clearInterval(timerId); clearInterval(timerId);
if (state == STATE_UNKNOWN) { if (state == STATE_UNKNOWN)
onStartSelect(pos); onStartSelect(pos);
} else if (state == STATE_DRAG) else if (state == STATE_DRAG)
onMouseDragSelectionEnd(); onMouseDragSelectionEnd();
else
self.$clickSelection = null; self.$clickSelection = null;
state = STATE_UNKNOWN; state = STATE_UNKNOWN;
}; };
@ -149,7 +148,6 @@ var MouseHandler = function(editor) {
dom.removeCssClass(editor.container, "ace_dragging"); dom.removeCssClass(editor.container, "ace_dragging");
if (!self.$clickSelection) { if (!self.$clickSelection) {
self.$clickSelection = null;
if (!dragCursor) { if (!dragCursor) {
editor.moveCursorToPosition(pos); editor.moveCursorToPosition(pos);
editor.selection.clearSelection(pos.row, pos.column); editor.selection.clearSelection(pos.row, pos.column);
@ -206,9 +204,10 @@ var MouseHandler = function(editor) {
if (e.shiftKey) if (e.shiftKey)
editor.selection.selectToPosition(pos) editor.selection.selectToPosition(pos)
else { else {
editor.moveCursorToPosition(pos); if (!self.$clickSelection) {
if (!editor.$clickSelection) editor.moveCursorToPosition(pos);
editor.selection.clearSelection(pos.row, pos.column); editor.selection.clearSelection(pos.row, pos.column);
}
} }
state = STATE_SELECT; state = STATE_SELECT;
} }
@ -217,7 +216,7 @@ var MouseHandler = function(editor) {
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY); var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1)); cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
if (self.$clickSelection) { if (self.$clickSelection) {
if (self.$clickSelection.contains(cursor.row, cursor.column)) { if (self.$clickSelection.contains(cursor.row, cursor.column)) {
editor.selection.setSelectionRange(self.$clickSelection); editor.selection.setSelectionRange(self.$clickSelection);
} else { } else {