allow focusing click to start selection if user really wants to
This commit is contained in:
parent
3c75fe1fbd
commit
231e5a7cb7
2 changed files with 14 additions and 6 deletions
|
|
@ -57,7 +57,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.setDefaultHandler("mousewheel", this.onScroll.bind(mouseHandler));
|
editor.setDefaultHandler("mousewheel", this.onScroll.bind(mouseHandler));
|
||||||
|
|
||||||
var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait",
|
var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait",
|
||||||
"dragWaitEnd", "startDrag"];
|
"dragWaitEnd", "startDrag", "focusWait"];
|
||||||
|
|
||||||
exports.forEach(function(x) {
|
exports.forEach(function(x) {
|
||||||
mouseHandler[x] = this[x];
|
mouseHandler[x] = this[x];
|
||||||
|
|
@ -98,8 +98,9 @@ function DefaultHandlers(mouseHandler) {
|
||||||
if (inSelection && !editor.isFocused()) {
|
if (inSelection && !editor.isFocused()) {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
if (this.$focusWaitTimout && !this.$clickSelection) {
|
if (this.$focusWaitTimout && !this.$clickSelection) {
|
||||||
// todo start select after focusWaitTimout passes
|
this.setState("focusWait");
|
||||||
return;
|
this.captureMouse(ev);
|
||||||
|
return ev.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +213,14 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.keyBinding.addKeyboardHandler(this.$dragKeybinding);
|
editor.keyBinding.addKeyboardHandler(this.$dragKeybinding);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.focusWait = function() {
|
||||||
|
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
||||||
|
var time = (new Date()).getTime();
|
||||||
|
|
||||||
|
if (distance > DRAG_OFFSET ||time - this.mousedownEvent.time > this.$focusWaitTimout)
|
||||||
|
this.startSelect();
|
||||||
|
};
|
||||||
|
|
||||||
this.dragWait = function() {
|
this.dragWait = function() {
|
||||||
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
||||||
var time = (new Date()).getTime();
|
var time = (new Date()).getTime();
|
||||||
|
|
@ -219,7 +228,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
|
|
||||||
if (distance > DRAG_OFFSET) {
|
if (distance > DRAG_OFFSET) {
|
||||||
this.startSelect();
|
this.startSelect();
|
||||||
} else if ((time - this.mousedownEvent.time) > editor.getDragDelay()) {
|
} else if (time - this.mousedownEvent.time > editor.getDragDelay()) {
|
||||||
this.startDrag()
|
this.startDrag()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -196,10 +196,9 @@ var RangeList = function() {
|
||||||
var lineDif = endRow - startRow;
|
var lineDif = endRow - startRow;
|
||||||
|
|
||||||
var colDiff = -start.column + end.column;
|
var colDiff = -start.column + end.column;
|
||||||
|
|
||||||
var ranges = this.ranges;
|
var ranges = this.ranges;
|
||||||
|
|
||||||
for (var i=0, n = ranges.length; i < n; i++) {
|
for (var i = 0, n = ranges.length; i < n; i++) {
|
||||||
var r = ranges[i];
|
var r = ranges[i];
|
||||||
if (r.end.row < startRow)
|
if (r.end.row < startRow)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue