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' ;
77import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
88import { ActionViewItem , BaseActionViewItem , SelectActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems' ;
99import { 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