Skip to content

Commit

Permalink
tvOS: Add drop-file support
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Sep 16, 2016
1 parent e5070d2 commit 4bcce33
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/video/uikit/SDL_uikitappdelegate.m
Expand Up @@ -464,17 +464,34 @@ - (void)applicationDidBecomeActive:(UIApplication*)application
}
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
- (void)sendDropFileForURL:(NSURL *)url
{
NSURL *fileURL = url.filePathURL;
if (fileURL != nil) {
SDL_SendDropFile(NULL, [fileURL.path UTF8String]);
SDL_SendDropFile(NULL, fileURL.path.UTF8String);
} else {
SDL_SendDropFile(NULL, [url.absoluteString UTF8String]);
SDL_SendDropFile(NULL, url.absoluteString.UTF8String);
}
SDL_SendDropComplete(NULL);
}

#if TARGET_OS_TV
/* TODO: Use this on iOS 9+ as well? */
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
/* TODO: Handle options */
[self sendDropFileForURL:url];
return YES;
}
#endif /* TARGET_OS_TV */

#if !TARGET_OS_TV
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
[self sendDropFileForURL:url];
return YES;
}
#endif /* !TARGET_OS_TV */

@end

Expand Down

0 comments on commit 4bcce33

Please sign in to comment.