mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-07 15:17:12 +01:00
LCL carbon: call Application.MainForm.Close on application quit command
git-svn-id: trunk@14626 -
This commit is contained in:
parent
d1a22ad097
commit
c483b4cea0
@ -66,6 +66,7 @@ type
|
||||
FMainMenu: TMainMenu; // Main menu attached to menu bar
|
||||
FCaptureWidget: HWND; // Captured widget (TCarbonWidget descendant)
|
||||
FOpenEventHandlerUPP: AEEventHandlerUPP;
|
||||
FQuitEventHandlerUPP: AEEventHandlerUPP;
|
||||
|
||||
function RawImage_DescriptionFromCarbonBitmap(out ADesc: TRawImageDescription; ABitmap: TCarbonBitmap): Boolean;
|
||||
function RawImage_FromCarbonBitmap(out ARawImage: TRawImage; ABitmap, AMask: TCarbonBitmap; const ARect: TRect): Boolean;
|
||||
|
||||
@ -261,9 +261,9 @@ var
|
||||
const
|
||||
SName = 'OpenDocEventHandler';
|
||||
begin
|
||||
//{$IFDEF VerboseAppEvent}
|
||||
{$IFDEF VerboseAppEvent}
|
||||
DebugLn('CarbonApp_Open');
|
||||
//{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
if OSError(AEGetParamDesc(AEvent, keyDirectObject, typeAEList, DocList),
|
||||
SName, 'AEGetParamDesc') then Exit;
|
||||
@ -313,6 +313,25 @@ begin
|
||||
Result := noErr;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: CarbonApp_Quit
|
||||
Handles application quit
|
||||
------------------------------------------------------------------------------}
|
||||
function CarbonApp_Quit(var AEvent: AppleEvent; var Reply: AppleEvent;
|
||||
Data: SInt32): OSErr; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||
begin
|
||||
{$IFDEF VerboseAppEvent}
|
||||
DebugLn('CarbonApp_Quit');
|
||||
{$ENDIF}
|
||||
|
||||
if (Application <> nil) and (Application.MainForm <> nil) then
|
||||
begin
|
||||
Application.MainForm.Close;
|
||||
end;
|
||||
|
||||
Result := noErr;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCarbonWidgetSet.AppInit
|
||||
Params: ScreenInfo
|
||||
@ -529,7 +548,8 @@ destructor TCarbonWidgetSet.Destroy;
|
||||
begin
|
||||
FreeAndNil(FTimerMap);
|
||||
DisposeAEEventHandlerUPP(FOpenEventHandlerUPP);
|
||||
|
||||
DisposeAEEventHandlerUPP(FQuitEventHandlerUPP);
|
||||
|
||||
inherited Destroy;
|
||||
CarbonWidgetSet := nil;
|
||||
end;
|
||||
@ -850,12 +870,16 @@ begin
|
||||
1, @TmpSpec, nil, nil);
|
||||
|
||||
FOpenEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Open));
|
||||
FQuitEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Quit));
|
||||
OSError(
|
||||
AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, FOpenEventHandlerUPP, 0, False),
|
||||
Self, SName, 'AEInstallEventHandler');
|
||||
OSError(
|
||||
AEInstallEventHandler(kCoreEventClass, kAEOpenContents, FOpenEventHandlerUPP, 0, False),
|
||||
Self, SName, 'AEInstallEventHandler');
|
||||
OSError(
|
||||
AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, FQuitEventHandlerUPP, 0, False),
|
||||
Self, SName, 'AEInstallEventHandler');
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user