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.captureMouse(e, "selectByLines");
|
||||
mouseHandler.setState("selectByLines");
|
||||
mouseHandler.captureMouse(e);
|
||||
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);
|
||||
return ev.preventDefault();
|
||||
};
|
||||
|
|
@ -101,13 +108,16 @@ function DefaultHandlers(mouseHandler) {
|
|||
this.startSelect = function(pos) {
|
||||
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||
var editor = this.editor;
|
||||
if (this.mousedownEvent.getShiftKey()) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
// allow double/triple click handlers to change selection
|
||||
setTimeout(function(){
|
||||
if (this.mousedownEvent.getShiftKey()) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
}.bind(this), 0);
|
||||
if (editor.container.setCapture) {
|
||||
editor.container.setCapture();
|
||||
}
|
||||
|
|
@ -221,6 +231,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
editor.selectAll();
|
||||
this.$clickSelection = editor.getSelectionRange();
|
||||
this.setState("null");
|
||||
this.selectEnd();
|
||||
};
|
||||
|
||||
this.onMouseWheel = function(ev) {
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ function DragdropHandler(mouseHandler) {
|
|||
var dataTransfer = e.dataTransfer;
|
||||
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
|
||||
dataTransfer.setDragImage && dataTransfer.setDragImage(proxy, 0, 0);
|
||||
// clear Opera garbage
|
||||
dataTransfer.clearData();
|
||||
dataTransfer.setData("Text", editor.session.getTextRange());
|
||||
|
||||
this.setState("drag");
|
||||
|
|
@ -327,7 +329,8 @@ function DragdropHandler(mouseHandler) {
|
|||
|
||||
var inSelection = e.inSelection();
|
||||
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();
|
||||
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
|
||||
if ("unselectable" in eventTarget)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue