mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 23:39:08 +02:00
cocoa: respecting bundle info.plist setting to create the proper applicaiton instance
git-svn-id: trunk@63693 -
This commit is contained in:
parent
909fb619f4
commit
62196c0992
@ -272,6 +272,16 @@ function CocoaPromptUser(const DialogCaption, DialogMessage: String;
|
|||||||
EscapeResult: Longint;
|
EscapeResult: Longint;
|
||||||
sheetOfWindow: NSWindow = nil; modalSheet: Boolean = false): Longint;
|
sheetOfWindow: NSWindow = nil; modalSheet: Boolean = false): Longint;
|
||||||
|
|
||||||
|
// The function tries to initialize the proper application class.
|
||||||
|
// The desired application class can be specified in info.plit
|
||||||
|
// by specifying NSPrincipalClass property.
|
||||||
|
// If then principal class has been found (in the bundle binaries)
|
||||||
|
// InitApplication function will try to call its "sharedApplication" method.
|
||||||
|
// If principle class is not specified, then TCocoaApplication is used.
|
||||||
|
// You should always specify either TCocoaApplication or
|
||||||
|
// a class derived from TCocoaApplication, in order for LCL to fucntion properly
|
||||||
|
function InitApplication: TCocoaApplication;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
@ -715,6 +725,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
AppClassMethod = objccategory external (NSObject)
|
||||||
|
function sharedApplication: NSApplication; message 'sharedApplication';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function InitApplication: TCocoaApplication;
|
||||||
|
var
|
||||||
|
bun : NSBundle;
|
||||||
|
begin
|
||||||
|
bun := NSBundle.mainBundle;
|
||||||
|
if Assigned(bun) and Assigned(bun.principalClass) then
|
||||||
|
Result := TCocoaApplication(NSObject(bun.principalClass).sharedApplication)
|
||||||
|
else
|
||||||
|
Result := TCocoaApplication(TCocoaApplication.sharedApplication);
|
||||||
|
end;
|
||||||
|
|
||||||
// the implementation of the utility methods
|
// the implementation of the utility methods
|
||||||
{$I cocoaobject.inc}
|
{$I cocoaobject.inc}
|
||||||
// the implementation of the winapi compatibility methods
|
// the implementation of the winapi compatibility methods
|
||||||
|
@ -38,7 +38,7 @@ begin
|
|||||||
ScreenInfo.PixelsPerInchY := CocoaBasePPI;
|
ScreenInfo.PixelsPerInchY := CocoaBasePPI;
|
||||||
|
|
||||||
{ Creates the application NSApp object }
|
{ Creates the application NSApp object }
|
||||||
FNSApp := TCocoaApplication(TCocoaApplication.sharedApplication);
|
FNSApp := InitApplication;
|
||||||
FNSApp_Delegate := TAppDelegate.alloc.init;
|
FNSApp_Delegate := TAppDelegate.alloc.init;
|
||||||
FNSApp.setDelegate(FNSApp_Delegate);
|
FNSApp.setDelegate(FNSApp_Delegate);
|
||||||
{$ifdef COCOALOOPOVERRIDE}
|
{$ifdef COCOALOOPOVERRIDE}
|
||||||
@ -52,7 +52,7 @@ end;
|
|||||||
|
|
||||||
procedure TCocoaWidgetSet.SendCheckSynchronizeMessage;
|
procedure TCocoaWidgetSet.SendCheckSynchronizeMessage;
|
||||||
begin
|
begin
|
||||||
TCocoaApplication.sharedApplication
|
InitApplication
|
||||||
.performSelectorOnMainThread_withObject_waitUntilDone(
|
.performSelectorOnMainThread_withObject_waitUntilDone(
|
||||||
ObjCSelector('lclSyncCheck:'), nil, false);
|
ObjCSelector('lclSyncCheck:'), nil, false);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user