mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
feat: enable secondary label for macOS menu (#46887)
* feat: enable secondary label for macOS menu * Update shell/browser/ui/cocoa/electron_menu_controller.mm Co-authored-by: Robo <hop2deep@gmail.com> * fix for lint * update docs for sublabel --------- Co-authored-by: Robo <hop2deep@gmail.com>
This commit is contained in:
committed by
GitHub
parent
b9f0aebb2f
commit
10e4f9ad37
@@ -315,12 +315,21 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
|
||||
- (NSMenuItem*)makeMenuItemForIndex:(NSInteger)index
|
||||
fromModel:(electron::ElectronMenuModel*)model {
|
||||
std::u16string label16 = model->GetLabelAt(index);
|
||||
auto rawSecondaryLabel = model->GetSecondaryLabelAt(index);
|
||||
NSString* label = l10n_util::FixUpWindowsStyleLabel(label16);
|
||||
|
||||
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:label
|
||||
action:@selector(itemSelected:)
|
||||
keyEquivalent:@""];
|
||||
|
||||
if (!rawSecondaryLabel.empty()) {
|
||||
if (@available(macOS 14.4, *)) {
|
||||
NSString* secondary_label =
|
||||
l10n_util::FixUpWindowsStyleLabel(rawSecondaryLabel);
|
||||
item.subtitle = secondary_label;
|
||||
}
|
||||
}
|
||||
|
||||
// If the menu item has an icon, set it.
|
||||
ui::ImageModel icon = model->GetIconAt(index);
|
||||
if (icon.IsImage())
|
||||
|
||||
Reference in New Issue
Block a user