Skip to content

Commit

Permalink
fix context menu in disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Jul 26, 2017
1 parent 9e80a12 commit 6a3b39b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,22 +317,29 @@ export class SelectionManager extends EventEmitter {
* @param event The mousedown event.
*/
private _onMouseDown(event: MouseEvent) {
// Ignore this event when selection is disabled
if (!this._enabled) {
if (!(Browser.isLinux ? event.shiftKey : event.altKey)) {
return;
} else {

// Don't send the mouse down event to the current process
event.stopPropagation();
}
// If we have selection, we want the context menu on right click
if (event.button === 2 && this.hasSelection) {
event.stopPropagation();
return;
}

// Only action the primary button
if (event.button !== 0) {
return;
}

// Allow selection when using a specific modifier key, even when disabled
if (!this._enabled) {
const shouldForceSelection = Browser.isMac ? event.altKey : event.shiftKey;

if (!shouldForceSelection) {
return;
}

// Don't send the mouse down event to the current process, we want to select
event.stopPropagation();
}

// Tell the browser not to start a regular selection
event.preventDefault();

Expand Down

0 comments on commit 6a3b39b

Please sign in to comment.