Skip to content

Commit 65e67d1

Browse files
authored
Make sure shift on Windows/Linux only works when hovering (microsoft#187310)
fixes microsoft#187265
1 parent 4a7c013 commit 65e67d1

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/vs/platform/actions/browser/menuEntryActionViewItem.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { $, addDisposableListener, append, asCSSUrl, EventType, IModifierKeyStatus, ModifierKeyEmitter, prepend } from 'vs/base/browser/dom';
6+
import { $, addDisposableListener, append, asCSSUrl, EventType, ModifierKeyEmitter, prepend } from 'vs/base/browser/dom';
77
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
88
import { ActionViewItem, BaseActionViewItem, SelectActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
99
import { DropdownMenuActionViewItem, IDropdownMenuActionViewItemOptions } from 'vs/base/browser/ui/dropdown/dropdownActionViewItem';
@@ -160,8 +160,13 @@ export class MenuEntryActionViewItem extends ActionViewItem {
160160
}
161161

162162
if (this._menuItemAction.alt) {
163-
const updateAltState = (keyStatus: IModifierKeyStatus) => {
164-
const wantsAltCommand = !!this._commandAction.alt?.enabled && (keyStatus.altKey || ((isWindows || isLinux) && keyStatus.shiftKey));
163+
let mouseOverOnWindowsOrLinux = false;
164+
165+
const updateAltState = () => {
166+
const wantsAltCommand = !!this._menuItemAction.alt?.enabled && (
167+
this._altKey.keyStatus.altKey
168+
|| (this._altKey.keyStatus.shiftKey && mouseOverOnWindowsOrLinux)
169+
);
165170

166171
if (wantsAltCommand !== this._wantsAltCommand) {
167172
this._wantsAltCommand = wantsAltCommand;
@@ -172,7 +177,20 @@ export class MenuEntryActionViewItem extends ActionViewItem {
172177
};
173178

174179
this._register(this._altKey.event(updateAltState));
175-
updateAltState(this._altKey.keyStatus);
180+
181+
if (isWindows || isLinux) {
182+
this._register(addDisposableListener(container, 'mouseleave', _ => {
183+
mouseOverOnWindowsOrLinux = false;
184+
updateAltState();
185+
}));
186+
187+
this._register(addDisposableListener(container, 'mouseenter', _ => {
188+
mouseOverOnWindowsOrLinux = true;
189+
updateAltState();
190+
}));
191+
}
192+
193+
updateAltState();
176194
}
177195
}
178196

0 commit comments

Comments
 (0)