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 - SDL does not handle URL Schemes in MacOS
Summary: SDL does not handle URL Schemes in MacOS
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.12
Hardware: All Mac OS X (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-04 15:14 UTC by Jason
Modified: 2020-04-05 17:48 UTC (History)
0 users

See Also:


Attachments
Additions on line 251 and 262 (17.00 KB, text/x-csrc)
2020-04-05 16:35 UTC, Jason
Details

Note You need to log in before you can comment on or make changes to this bug.
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