diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 14439ca2..c7343cf5 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -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.