We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5073

Summary: SDL does not handle URL Schemes in MacOS
Product: SDL Reporter: Jason <Jason.carr01>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.12   
Hardware: All   
OS: Mac OS X (All)   
Attachments: Additions on line 251 and 262

Description Jason 2020-04-04 15:14:29 UTC
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. 

As a quick fix, I modified the app delegate defined in src/video/cocoa/SDL_cocoaevents.m

Added to applicationDidFinishLaunching (line 205)
[[NSAppleEventManager sharedAppleEventManager]
    setEventHandler:self
        andSelector:@selector(handleURLEvent:withReplyEvent:)
      forEventClass:kInternetEventClass
         andEventID:kAEGetURL];




-----------------------------------------
Added after applicationDidFinishLaunching 

- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
    NSString* path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
    SDL_SendDropFile(NULL, [path UTF8String]);
    SDL_SendDropComplete(NULL);
}
Comment 1 Sam Lantinga 2020-04-05 15:49:33 UTC
Can you attach your SDL_cocoaevents.m file, so I can see the context? Line 205 is in a different function here.

Thanks!
Comment 2 Jason 2020-04-05 16:35:59 UTC
Created attachment 4293 [details]
Additions on line 251 and 262
Comment 3 Sam Lantinga 2020-04-05 17:48:23 UTC
Changes committed, thanks!
https://hg.libsdl.org/SDL/rev/19139846279c