Fix dbl/triple click issues of native dnd
This commit is contained in:
parent
cb7a0d5d47
commit
b1ba675cfd
3 changed files with 25 additions and 10 deletions
|
|
@ -57,7 +57,8 @@ function GutterHandler(mouseHandler) {
|
||||||
}
|
}
|
||||||
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
|
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
|
||||||
}
|
}
|
||||||
mouseHandler.captureMouse(e, "selectByLines");
|
mouseHandler.setState("selectByLines");
|
||||||
|
mouseHandler.captureMouse(e);
|
||||||
return e.preventDefault();
|
return e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,14 @@ function DefaultHandlers(mouseHandler) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startSelect(pos, true);
|
if (!inSelection || this.$clickSelection || ev.getShiftKey() || editor.inMultiSelectMode) {
|
||||||
|
// Directly pick STATE_SELECT, since the user is not clicking inside
|
||||||
|
// a selection.
|
||||||
|
this.startSelect(pos);
|
||||||
|
} else if (inSelection) {
|
||||||
|
this.mousedownEvent.time = (new Date()).getTime();
|
||||||
|
this.startSelect(pos);
|
||||||
|
}
|
||||||
this.captureMouse(ev);
|
this.captureMouse(ev);
|
||||||
return ev.preventDefault();
|
return ev.preventDefault();
|
||||||
};
|
};
|
||||||
|
|
@ -101,6 +108,8 @@ function DefaultHandlers(mouseHandler) {
|
||||||
this.startSelect = function(pos) {
|
this.startSelect = function(pos) {
|
||||||
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||||
var editor = this.editor;
|
var editor = this.editor;
|
||||||
|
// allow double/triple click handlers to change selection
|
||||||
|
setTimeout(function(){
|
||||||
if (this.mousedownEvent.getShiftKey()) {
|
if (this.mousedownEvent.getShiftKey()) {
|
||||||
editor.selection.selectToPosition(pos);
|
editor.selection.selectToPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +117,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.moveCursorToPosition(pos);
|
editor.moveCursorToPosition(pos);
|
||||||
editor.selection.clearSelection();
|
editor.selection.clearSelection();
|
||||||
}
|
}
|
||||||
|
}.bind(this), 0);
|
||||||
if (editor.container.setCapture) {
|
if (editor.container.setCapture) {
|
||||||
editor.container.setCapture();
|
editor.container.setCapture();
|
||||||
}
|
}
|
||||||
|
|
@ -221,6 +231,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.selectAll();
|
editor.selectAll();
|
||||||
this.$clickSelection = editor.getSelectionRange();
|
this.$clickSelection = editor.getSelectionRange();
|
||||||
this.setState("null");
|
this.setState("null");
|
||||||
|
this.selectEnd();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onMouseWheel = function(ev) {
|
this.onMouseWheel = function(ev) {
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,8 @@ function DragdropHandler(mouseHandler) {
|
||||||
var dataTransfer = e.dataTransfer;
|
var dataTransfer = e.dataTransfer;
|
||||||
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
|
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
|
||||||
dataTransfer.setDragImage && dataTransfer.setDragImage(proxy, 0, 0);
|
dataTransfer.setDragImage && dataTransfer.setDragImage(proxy, 0, 0);
|
||||||
|
// clear Opera garbage
|
||||||
|
dataTransfer.clearData();
|
||||||
dataTransfer.setData("Text", editor.session.getTextRange());
|
dataTransfer.setData("Text", editor.session.getTextRange());
|
||||||
|
|
||||||
this.setState("drag");
|
this.setState("drag");
|
||||||
|
|
@ -327,7 +329,8 @@ function DragdropHandler(mouseHandler) {
|
||||||
|
|
||||||
var inSelection = e.inSelection();
|
var inSelection = e.inSelection();
|
||||||
var button = e.getButton();
|
var button = e.getButton();
|
||||||
if (button === 0 && inSelection) {
|
var clickCount = e.domEvent.detail || 1;
|
||||||
|
if (clickCount === 1 && button === 0 && inSelection) {
|
||||||
this.mousedownEvent.time = (new Date()).getTime();
|
this.mousedownEvent.time = (new Date()).getTime();
|
||||||
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
|
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
|
||||||
if ("unselectable" in eventTarget)
|
if ("unselectable" in eventTarget)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue