Cocoa: add TCocoaConfigAppMenu.onCreate for custom

This commit is contained in:
rich2014 2024-10-12 19:00:14 +08:00
parent da931797db
commit 1259df9b51
3 changed files with 10 additions and 0 deletions

View File

@ -21,6 +21,7 @@ var
aboutItem: nil;
preferencesItem: nil;
customMenus: nil;
onCreate: nil;
dontAutoCreateItems: False;
);

View File

@ -115,6 +115,8 @@ type
defaultRadioImageName: NSString;
end;
TCocoaConfigAppMenuOnCreate = procedure ( appMenu: NSMenu );
// Application interface provided to facilitate APP to operate App Menu.
// it's easy to set About, Preferences, and customized menus,
// only the LCL TMenuItem is needed to pass in.
@ -124,6 +126,7 @@ type
aboutItem: TMenuItem;
preferencesItem: TMenuItem;
customMenus: TMenuItem;
onCreate: TCocoaConfigAppMenuOnCreate;
dontAutoCreateItems: Boolean;
end;

View File

@ -523,6 +523,12 @@ begin
rsMacOSMenuPreferences,
VK_OEM_COMMA, [ssMeta]);
// Custom onCreate
if Assigned( CocoaConfigMenu.appMenu.onCreate ) then begin
submenu.addItem( NSMenuItem.separatorItem );
CocoaConfigMenu.appMenu.onCreate( submenu );
end;
// Auto Create App Menu below?
if CocoaConfigMenu.appMenu.dontAutoCreateItems then
Exit;