feat: add MenuItem.userAccelerator property (#26682)
* feat: add MenuItem.userAccelerator property This allows folks to read the user-assigned accelerator that macOS users can provide in system preferences. Useful for showing in-app shortcut help dialogs, you need to know if the accelerator you provided is not being used in favor of a user assigned one. * chore: update syntax * chore: add safety check for command index being -1
This commit is contained in:
parent
3e69985b76
commit
da9261497e
7 changed files with 85 additions and 9 deletions
|
@ -315,11 +315,9 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
|||
return item.autorelease();
|
||||
}
|
||||
|
||||
// Adds an item or a hierarchical menu to the item at the |index|,
|
||||
// associated with the entry in the model identified by |modelIndex|.
|
||||
- (void)addItemToMenu:(NSMenu*)menu
|
||||
atIndex:(NSInteger)index
|
||||
fromModel:(electron::ElectronMenuModel*)model {
|
||||
- (base::scoped_nsobject<NSMenuItem>)
|
||||
makeMenuItemForIndex:(NSInteger)index
|
||||
fromModel:(electron::ElectronMenuModel*)model {
|
||||
std::u16string label16 = model->GetLabelAt(index);
|
||||
NSString* label = l10n_util::FixUpWindowsStyleLabel(label16);
|
||||
|
||||
|
@ -437,7 +435,17 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
|||
}
|
||||
}
|
||||
}
|
||||
[menu insertItem:item atIndex:index];
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
// Adds an item or a hierarchical menu to the item at the |index|,
|
||||
// associated with the entry in the model identified by |modelIndex|.
|
||||
- (void)addItemToMenu:(NSMenu*)menu
|
||||
atIndex:(NSInteger)index
|
||||
fromModel:(electron::ElectronMenuModel*)model {
|
||||
[menu insertItem:[self makeMenuItemForIndex:index fromModel:model]
|
||||
atIndex:index];
|
||||
}
|
||||
|
||||
// Called before the menu is to be displayed to update the state (enabled,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue