Merge pull request #9154 from be5invis/master
This commit is contained in:
commit
101ad8c222
2 changed files with 66 additions and 0 deletions
|
@ -26,6 +26,7 @@ import 'vs/editor/contrib/linesOperations/common/linesOperations';
|
||||||
import 'vs/editor/contrib/carretOperations/common/carretOperations';
|
import 'vs/editor/contrib/carretOperations/common/carretOperations';
|
||||||
import 'vs/editor/contrib/links/browser/links';
|
import 'vs/editor/contrib/links/browser/links';
|
||||||
import 'vs/editor/contrib/multicursor/common/multicursor';
|
import 'vs/editor/contrib/multicursor/common/multicursor';
|
||||||
|
import 'vs/editor/contrib/multicursor/browser/menuPreventer';
|
||||||
import 'vs/editor/contrib/parameterHints/browser/parameterHints';
|
import 'vs/editor/contrib/parameterHints/browser/parameterHints';
|
||||||
import 'vs/editor/contrib/quickFix/browser/quickFix';
|
import 'vs/editor/contrib/quickFix/browser/quickFix';
|
||||||
import 'vs/editor/contrib/referenceSearch/browser/referenceSearch';
|
import 'vs/editor/contrib/referenceSearch/browser/referenceSearch';
|
||||||
|
|
65
src/vs/editor/contrib/multicursor/browser/menuPreventer.ts
Normal file
65
src/vs/editor/contrib/multicursor/browser/menuPreventer.ts
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import {KeyMod} from 'vs/base/common/keyCodes';
|
||||||
|
import {Disposable} from 'vs/base/common/lifecycle';
|
||||||
|
import {IEditorContribution} from 'vs/editor/common/editorCommon';
|
||||||
|
import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
|
||||||
|
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevents the top-level menu from showing up when doing Alt + Click in the editor
|
||||||
|
*/
|
||||||
|
export class MenuPreventer extends Disposable implements IEditorContribution {
|
||||||
|
|
||||||
|
private static ID = 'editor.contrib.menuPreventer';
|
||||||
|
|
||||||
|
private _editor:ICodeEditor;
|
||||||
|
private _altListeningMouse:boolean;
|
||||||
|
private _altMouseTriggered:boolean;
|
||||||
|
|
||||||
|
constructor(editor:ICodeEditor) {
|
||||||
|
super();
|
||||||
|
this._editor = editor;
|
||||||
|
this._altListeningMouse = false;
|
||||||
|
this._altMouseTriggered = false;
|
||||||
|
|
||||||
|
// A global crossover handler to prevent menu bar from showing up
|
||||||
|
// When <alt> is hold, we will listen to mouse events and prevent
|
||||||
|
// the release event up <alt> if the mouse is triggered.
|
||||||
|
|
||||||
|
this._register(this._editor.onMouseDown((e) => {
|
||||||
|
if (this._altListeningMouse) {
|
||||||
|
this._altMouseTriggered = true;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
this._register(this._editor.onKeyDown((e) => {
|
||||||
|
if (e.equals(KeyMod.Alt)) {
|
||||||
|
if (!this._altListeningMouse) {
|
||||||
|
this._altMouseTriggered = false;
|
||||||
|
}
|
||||||
|
this._altListeningMouse = true;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
this._register(this._editor.onKeyUp((e) => {
|
||||||
|
if (e.equals(KeyMod.Alt)) {
|
||||||
|
if(this._altMouseTriggered){
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
this._altListeningMouse = false;
|
||||||
|
this._altMouseTriggered = false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
public getId(): string {
|
||||||
|
return MenuPreventer.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorBrowserRegistry.registerEditorContribution(MenuPreventer);
|
Loading…
Reference in a new issue