revert: allow NSMenuItems to be disabled (#46521)
Revert "fix: allow NSMenuItems to be disabled (#46307)"
This reverts commit ac616ef41d
.
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Hailey <hschauman@slack-corp.com>
This commit is contained in:
parent
e76f986aa9
commit
446128bc14
1 changed files with 6 additions and 9 deletions
|
@ -320,10 +320,6 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
|
||||||
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:label
|
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:label
|
||||||
action:@selector(itemSelected:)
|
action:@selector(itemSelected:)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
if (model->IsEnabledAt(index))
|
|
||||||
[item setEnabled:YES];
|
|
||||||
else
|
|
||||||
[item setEnabled:NO];
|
|
||||||
|
|
||||||
// If the menu item has an icon, set it.
|
// If the menu item has an icon, set it.
|
||||||
ui::ImageModel icon = model->GetIconAt(index);
|
ui::ImageModel icon = model->GetIconAt(index);
|
||||||
|
@ -353,6 +349,11 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
|
||||||
[item setSubmenu:[self createShareMenuForItem:sharing_item]];
|
[item setSubmenu:[self createShareMenuForItem:sharing_item]];
|
||||||
} else if (type == electron::ElectronMenuModel::TYPE_SUBMENU &&
|
} else if (type == electron::ElectronMenuModel::TYPE_SUBMENU &&
|
||||||
model->IsVisibleAt(index)) {
|
model->IsVisibleAt(index)) {
|
||||||
|
// We need to specifically check that the submenu top-level item has been
|
||||||
|
// enabled as it's not validated by validateUserInterfaceItem
|
||||||
|
if (!model->IsEnabledAt(index))
|
||||||
|
[item setEnabled:NO];
|
||||||
|
|
||||||
// Recursively build a submenu from the sub-model at this index.
|
// Recursively build a submenu from the sub-model at this index.
|
||||||
[item setTarget:nil];
|
[item setTarget:nil];
|
||||||
[item setAction:nil];
|
[item setAction:nil];
|
||||||
|
@ -492,10 +493,8 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMenu*)menu {
|
- (NSMenu*)menu {
|
||||||
if (menu_) {
|
if (menu_)
|
||||||
[menu_ setAutoenablesItems:NO];
|
|
||||||
return menu_;
|
return menu_;
|
||||||
}
|
|
||||||
|
|
||||||
if (model_ && model_->sharing_item()) {
|
if (model_ && model_->sharing_item()) {
|
||||||
NSMenu* menu = [self createShareMenuForItem:*model_->sharing_item()];
|
NSMenu* menu = [self createShareMenuForItem:*model_->sharing_item()];
|
||||||
|
@ -505,8 +504,6 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
|
||||||
if (model_)
|
if (model_)
|
||||||
[self populateWithModel:model_.get()];
|
[self populateWithModel:model_.get()];
|
||||||
}
|
}
|
||||||
|
|
||||||
[menu_ setAutoenablesItems:NO];
|
|
||||||
[menu_ setDelegate:self];
|
[menu_ setDelegate:self];
|
||||||
return menu_;
|
return menu_;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue