mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
fix: allow disabling all NSMenuItems (#48711)
fix: allow disabling all NSMenuItems Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -25,11 +25,30 @@ Menu.prototype._isCommandIdChecked = function (id) {
|
||||
};
|
||||
|
||||
Menu.prototype._isCommandIdEnabled = function (id) {
|
||||
return this.commandsMap[id] ? this.commandsMap[id].enabled : false;
|
||||
const item = this.commandsMap[id];
|
||||
if (!item) return false;
|
||||
|
||||
const focusedWindow = BaseWindow.getFocusedWindow();
|
||||
|
||||
if (item.role === 'minimize' && focusedWindow) {
|
||||
return focusedWindow.isMinimizable();
|
||||
}
|
||||
|
||||
if (item.role === 'togglefullscreen' && focusedWindow) {
|
||||
return focusedWindow.isFullScreenable();
|
||||
}
|
||||
|
||||
if (item.role === 'close' && focusedWindow) {
|
||||
return focusedWindow.isClosable();
|
||||
}
|
||||
|
||||
return item.enabled;
|
||||
};
|
||||
|
||||
Menu.prototype._shouldCommandIdWorkWhenHidden = function (id) {
|
||||
return this.commandsMap[id] ? !!this.commandsMap[id].acceleratorWorksWhenHidden : false;
|
||||
};
|
||||
|
||||
Menu.prototype._isCommandIdVisible = function (id) {
|
||||
return this.commandsMap[id] ? this.commandsMap[id].visible : false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user