mirror of https://github.com/encounter/SDL.git
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.
This commit is contained in:
parent
9525f9729a
commit
dad73b1f0c
|
@ -248,10 +248,24 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[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
|
/* If we call this before NSApp activation, macOS might print a complaint
|
||||||
* about ApplePersistenceIgnoreState. */
|
* about ApplePersistenceIgnoreState. */
|
||||||
[SDLApplication registerUserDefaults];
|
[SDLApplication registerUserDefaults];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
||||||
|
{
|
||||||
|
NSString* path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||||
|
SDL_SendDropFile(NULL, [path UTF8String]);
|
||||||
|
SDL_SendDropComplete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static SDLAppDelegate *appDelegate = nil;
|
static SDLAppDelegate *appDelegate = nil;
|
||||||
|
|
Loading…
Reference in New Issue