|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 |
| -import { $, addDisposableListener, append, asCSSUrl, EventType, ModifierKeyEmitter, prepend } from 'vs/base/browser/dom'; |
| 6 | +import { $, addDisposableListener, append, asCSSUrl, EventType, IModifierKeyStatus, ModifierKeyEmitter, prepend } from 'vs/base/browser/dom'; |
7 | 7 | import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
8 | 8 | import { ActionViewItem, BaseActionViewItem, SelectActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
|
9 | 9 | import { DropdownMenuActionViewItem, IDropdownMenuActionViewItemOptions } from 'vs/base/browser/ui/dropdown/dropdownActionViewItem';
|
@@ -159,36 +159,21 @@ export class MenuEntryActionViewItem extends ActionViewItem {
|
159 | 159 | this._updateItemClass(this._menuItemAction.item);
|
160 | 160 | }
|
161 | 161 |
|
162 |
| - let mouseOver = false; |
163 |
| - |
164 |
| - let alternativeKeyDown = this._altKey.keyStatus.altKey || ((isWindows || isLinux) && this._altKey.keyStatus.shiftKey); |
165 |
| - |
166 |
| - const updateAltState = () => { |
167 |
| - const wantsAltCommand = mouseOver && alternativeKeyDown && !!this._commandAction.alt?.enabled; |
168 |
| - if (wantsAltCommand !== this._wantsAltCommand) { |
169 |
| - this._wantsAltCommand = wantsAltCommand; |
170 |
| - this.updateLabel(); |
171 |
| - this.updateTooltip(); |
172 |
| - this.updateClass(); |
173 |
| - } |
174 |
| - }; |
175 |
| - |
176 | 162 | if (this._menuItemAction.alt) {
|
177 |
| - this._register(this._altKey.event(value => { |
178 |
| - alternativeKeyDown = value.altKey || ((isWindows || isLinux) && value.shiftKey); |
179 |
| - updateAltState(); |
180 |
| - })); |
181 |
| - } |
| 163 | + const updateAltState = (keyStatus: IModifierKeyStatus) => { |
| 164 | + const wantsAltCommand = !!this._commandAction.alt?.enabled && (keyStatus.altKey || ((isWindows || isLinux) && keyStatus.shiftKey)); |
182 | 165 |
|
183 |
| - this._register(addDisposableListener(container, 'mouseleave', _ => { |
184 |
| - mouseOver = false; |
185 |
| - updateAltState(); |
186 |
| - })); |
| 166 | + if (wantsAltCommand !== this._wantsAltCommand) { |
| 167 | + this._wantsAltCommand = wantsAltCommand; |
| 168 | + this.updateLabel(); |
| 169 | + this.updateTooltip(); |
| 170 | + this.updateClass(); |
| 171 | + } |
| 172 | + }; |
187 | 173 |
|
188 |
| - this._register(addDisposableListener(container, 'mouseenter', _ => { |
189 |
| - mouseOver = true; |
190 |
| - updateAltState(); |
191 |
| - })); |
| 174 | + this._register(this._altKey.event(updateAltState)); |
| 175 | + updateAltState(this._altKey.keyStatus); |
| 176 | + } |
192 | 177 | }
|
193 | 178 |
|
194 | 179 | protected override updateLabel(): void {
|
|
0 commit comments