fix right click selection bug

This commit is contained in:
nightwing 2012-04-26 19:50:19 +04:00
commit 8391b59feb

View file

@ -76,6 +76,19 @@ function DefaultHandlers(editor) {
var selectionEmpty = selectionRange.isEmpty();
var state = STATE_UNKNOWN;
var button = ev.getButton();
if (button !== 0) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
editor.selection.clearSelection();
}
if (button == 2) {
editor.textInput.onContextMenu({x: ev.clientX, y: ev.clientY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
}
return;
}
// if this click caused the editor to be focused should not clear the
// selection
if (
@ -89,18 +102,6 @@ function DefaultHandlers(editor) {
return;
}
var button = ev.getButton();
if (button !== 0) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
}
if (button == 2) {
editor.textInput.onContextMenu({x: ev.clientX, y: ev.clientY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
}
return;
}
if (!inSelection) {
// Directly pick STATE_SELECT, since the user is not clicking inside
// a selection.