Skip to content

Commit

Permalink
Fixed bug 5073 - SDL does not handle URL Schemes in MacOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Apr 5, 2020
1 parent 9525f97 commit dad73b1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/video/cocoa/SDL_cocoaevents.m
Expand Up @@ -248,10 +248,24 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
[NSApp activateIgnoringOtherApps:YES];
}

[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self
andSelector:@selector(handleURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];

/* If we call this before NSApp activation, macOS might print a complaint
* about ApplePersistenceIgnoreState. */
[SDLApplication registerUserDefaults];
}

- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString* path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
SDL_SendDropFile(NULL, [path UTF8String]);
SDL_SendDropComplete(NULL);
}

@end

static SDLAppDelegate *appDelegate = nil;
Expand Down

0 comments on commit dad73b1

Please sign in to comment.