| @@ -96,26 +96,36 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| struct AppDelegateClass : public ObjCClass <NSObject> | |||||
| struct AppDelegateClass : public ObjCClass<NSObject> | |||||
| { | { | ||||
| AppDelegateClass() : ObjCClass <NSObject> ("JUCEAppDelegate_") | |||||
| AppDelegateClass() : ObjCClass<NSObject> ("JUCEAppDelegate_") | |||||
| { | { | ||||
| addMethod (@selector (applicationShouldTerminate:), applicationShouldTerminate, "I@:@"); | |||||
| addMethod (@selector (applicationWillTerminate:), applicationWillTerminate, "v@:@"); | |||||
| addMethod (@selector (application:openFile:), application_openFile, "c@:@@"); | |||||
| addMethod (@selector (application:openFiles:), application_openFiles, "v@:@@"); | |||||
| addMethod (@selector (applicationDidBecomeActive:), applicationDidBecomeActive, "v@:@"); | |||||
| addMethod (@selector (applicationDidResignActive:), applicationDidResignActive, "v@:@"); | |||||
| addMethod (@selector (applicationWillUnhide:), applicationWillUnhide, "v@:@"); | |||||
| addMethod (@selector (broadcastMessageCallback:), broadcastMessageCallback, "v@:@"); | |||||
| addMethod (@selector (mainMenuTrackingBegan:), mainMenuTrackingBegan, "v@:@"); | |||||
| addMethod (@selector (mainMenuTrackingEnded:), mainMenuTrackingEnded, "v@:@"); | |||||
| addMethod (@selector (dummyMethod), dummyMethod, "v@:"); | |||||
| addMethod (@selector (applicationWillFinishLaunching:), applicationWillFinishLaunching, "v@:@@"); | |||||
| addMethod (@selector (getUrl:withReplyEvent:), getUrl_withReplyEvent, "v@:@@"); | |||||
| addMethod (@selector (applicationShouldTerminate:), applicationShouldTerminate, "I@:@"); | |||||
| addMethod (@selector (applicationWillTerminate:), applicationWillTerminate, "v@:@"); | |||||
| addMethod (@selector (application:openFile:), application_openFile, "c@:@@"); | |||||
| addMethod (@selector (application:openFiles:), application_openFiles, "v@:@@"); | |||||
| addMethod (@selector (applicationDidBecomeActive:), applicationDidBecomeActive, "v@:@"); | |||||
| addMethod (@selector (applicationDidResignActive:), applicationDidResignActive, "v@:@"); | |||||
| addMethod (@selector (applicationWillUnhide:), applicationWillUnhide, "v@:@"); | |||||
| addMethod (@selector (broadcastMessageCallback:), broadcastMessageCallback, "v@:@"); | |||||
| addMethod (@selector (mainMenuTrackingBegan:), mainMenuTrackingBegan, "v@:@"); | |||||
| addMethod (@selector (mainMenuTrackingEnded:), mainMenuTrackingEnded, "v@:@"); | |||||
| addMethod (@selector (dummyMethod), dummyMethod, "v@:"); | |||||
| registerClass(); | registerClass(); | ||||
| } | } | ||||
| private: | private: | ||||
| static void applicationWillFinishLaunching (id self, SEL, NSApplication*, NSNotification*) | |||||
| { | |||||
| [[NSAppleEventManager sharedAppleEventManager] setEventHandler: self | |||||
| andSelector: @selector (getUrl:withReplyEvent:) | |||||
| forEventClass: kInternetEventClass | |||||
| andEventID: kAEGetURL]; | |||||
| } | |||||
| static NSApplicationTerminateReply applicationShouldTerminate (id /*self*/, SEL, NSApplication*) | static NSApplicationTerminateReply applicationShouldTerminate (id /*self*/, SEL, NSApplication*) | ||||
| { | { | ||||
| if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance()) | if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance()) | ||||
| @@ -184,13 +194,18 @@ private: | |||||
| static void dummyMethod (id /*self*/, SEL) {} // (used as a way of running a dummy thread) | static void dummyMethod (id /*self*/, SEL) {} // (used as a way of running a dummy thread) | ||||
| private: | |||||
| static void focusChanged() | static void focusChanged() | ||||
| { | { | ||||
| if (appFocusChangeCallback != nullptr) | if (appFocusChangeCallback != nullptr) | ||||
| (*appFocusChangeCallback)(); | (*appFocusChangeCallback)(); | ||||
| } | } | ||||
| static void getUrl_withReplyEvent (id /*self*/, SEL, NSAppleEventDescriptor* event, NSAppleEventDescriptor*) | |||||
| { | |||||
| if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance()) | |||||
| app->anotherInstanceStarted (quotedIfContainsSpaces ([[event paramDescriptorForKeyword: keyDirectObject] stringValue])); | |||||
| } | |||||
| static String quotedIfContainsSpaces (NSString* file) | static String quotedIfContainsSpaces (NSString* file) | ||||
| { | { | ||||
| String s (nsStringToJuce (file)); | String s (nsStringToJuce (file)); | ||||