mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 01:00:34 +02:00
Cocoa: macOS_DockMenuIntf added to facilitate APP to operate Dock Menu
This commit is contained in:
parent
4df4532e13
commit
648a0b25fc
@ -62,6 +62,7 @@ type
|
||||
procedure applicationDidResignActive(notification: NSNotification);
|
||||
procedure applicationDidChangeScreenParameters(notification: NSNotification);
|
||||
procedure applicationWillFinishLaunching(notification: NSNotification);
|
||||
function applicationDockMenu(sender: NSApplication): NSMenu;
|
||||
procedure handleQuitAppEvent_withReplyEvent(event: NSAppleEventDescriptor; replyEvent: NSAppleEventDescriptor); message 'handleQuitAppEvent:withReplyEvent:';
|
||||
end;
|
||||
|
||||
|
@ -78,6 +78,15 @@ type
|
||||
dontAutoCreateAppMenuItems: Boolean;
|
||||
end;
|
||||
|
||||
{ TMacOS_DockMenuIntf }
|
||||
|
||||
// Application interface provided to facilitate APP to operate Dock Menu.
|
||||
// only the LCL TMenuItem is needed to pass in.
|
||||
TMacOS_DockMenuIntf = class
|
||||
public
|
||||
customMenus: TMenuItem;
|
||||
end;
|
||||
|
||||
TMenuItemHandleCreateFunc = function(const AMenuItem: TMenuItem): NSMenuItem;
|
||||
|
||||
const
|
||||
@ -85,6 +94,7 @@ const
|
||||
|
||||
var
|
||||
macOS_AppMenuIntf: TMacOS_AppMenuIntf;
|
||||
macOS_DockMenuIntf: TMacOS_DockMenuIntf;
|
||||
menuItemHandleCreateFunc: TMenuItemHandleCreateFunc;
|
||||
|
||||
procedure MenuTrackStarted(mn: NSMenu);
|
||||
@ -715,11 +725,13 @@ end;
|
||||
|
||||
initialization
|
||||
macOS_AppMenuIntf:= TMacOS_AppMenuIntf.Create;
|
||||
macOS_DockMenuIntf:= TMacOS_DockMenuIntf.Create;
|
||||
|
||||
finalization
|
||||
MenuTrackCancelAll;
|
||||
if menuTrack <> nil then menuTrack.release;
|
||||
FreeAndNil(macOS_AppMenuIntf);
|
||||
FreeAndNil(macOS_DockMenuIntf);
|
||||
|
||||
end.
|
||||
|
||||
|
@ -722,6 +722,13 @@ begin
|
||||
kAEQuitApplication);
|
||||
end;
|
||||
|
||||
function TAppDelegate.applicationDockMenu(sender: NSApplication): NSMenu;
|
||||
begin
|
||||
Result:= NSMenu.alloc.init;
|
||||
if Assigned(macOS_DockMenuIntf.customMenus) then
|
||||
NSMenuAddItemsFromLCLMenu(Result, macOS_DockMenuIntf.customMenus);
|
||||
end;
|
||||
|
||||
procedure TAppDelegate.handleQuitAppEvent_withReplyEvent(event: NSAppleEventDescriptor; replyEvent: NSAppleEventDescriptor);
|
||||
{ Capture "Quit Application" Apple Events, either from system shutdown/logout
|
||||
or sent by another application. Don't use [applicationShouldTerminate:]
|
||||
|
Loading…
Reference in New Issue
Block a user