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));
|
||||
|
||||
var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait",
|
||||
"dragWaitEnd", "startDrag"];
|
||||
"dragWaitEnd", "startDrag", "focusWait"];
|
||||
|
||||
exports.forEach(function(x) {
|
||||
mouseHandler[x] = this[x];
|
||||
|
|
@ -98,8 +98,9 @@ function DefaultHandlers(mouseHandler) {
|
|||
if (inSelection && !editor.isFocused()) {
|
||||
editor.focus();
|
||||
if (this.$focusWaitTimout && !this.$clickSelection) {
|
||||
// todo start select after focusWaitTimout passes
|
||||
return;
|
||||
this.setState("focusWait");
|
||||
this.captureMouse(ev);
|
||||
return ev.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,6 +213,14 @@ function DefaultHandlers(mouseHandler) {
|
|||
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() {
|
||||
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
||||
var time = (new Date()).getTime();
|
||||
|
|
@ -219,7 +228,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
|
||||
if (distance > DRAG_OFFSET) {
|
||||
this.startSelect();
|
||||
} else if ((time - this.mousedownEvent.time) > editor.getDragDelay()) {
|
||||
} else if (time - this.mousedownEvent.time > editor.getDragDelay()) {
|
||||
this.startDrag()
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -196,10 +196,9 @@ var RangeList = function() {
|
|||
var lineDif = endRow - startRow;
|
||||
|
||||
var colDiff = -start.column + end.column;
|
||||
|
||||
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];
|
||||
if (r.end.row < startRow)
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue