Fixed bug 5073 - SDL does not handle URL Schemes in MacOS
authorSam Lantinga
Sun, 05 Apr 2020 10:47:58 -0700
changeset 1369219139846279c
parent 13691 10a795c0dd52
child 13693 d075df3ffa57
Fixed bug 5073 - SDL does not handle URL Schemes in MacOS

Jason

In iOS, URL Events trigger the DropFile event. I would also expect the same event to be fired on the macOS platform but this is not implemented at all in the AppDelegate.
src/video/cocoa/SDL_cocoaevents.m
     1.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Sun Apr 05 10:44:51 2020 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Sun Apr 05 10:47:58 2020 -0700
     1.3 @@ -248,10 +248,24 @@
     1.4          [NSApp activateIgnoringOtherApps:YES];
     1.5      }
     1.6  
     1.7 +    [[NSAppleEventManager sharedAppleEventManager]
     1.8 +    setEventHandler:self
     1.9 +        andSelector:@selector(handleURLEvent:withReplyEvent:)
    1.10 +      forEventClass:kInternetEventClass
    1.11 +         andEventID:kAEGetURL];
    1.12 +
    1.13      /* If we call this before NSApp activation, macOS might print a complaint
    1.14       * about ApplePersistenceIgnoreState. */
    1.15      [SDLApplication registerUserDefaults];
    1.16  }
    1.17 +
    1.18 +- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
    1.19 +{
    1.20 +    NSString* path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
    1.21 +    SDL_SendDropFile(NULL, [path UTF8String]);
    1.22 +    SDL_SendDropComplete(NULL);
    1.23 +}
    1.24 +
    1.25  @end
    1.26  
    1.27  static SDLAppDelegate *appDelegate = nil;