README-macosx.txt
changeset 7801 f00cc0a8cd5d
parent 7222 2435b221d77d
child 8191 b50f4ae6d5f2
--- a/README-macosx.txt	Thu Oct 10 02:37:36 2013 -0400
+++ b/README-macosx.txt	Mon Oct 07 16:01:40 2013 -0700
@@ -30,6 +30,42 @@
 use the traditional autoconf/automake/make method, or use Xcode.
 
 ==============================================================================
+Caveats for using SDL with Mac OS X
+==============================================================================
+
+Some things you have to be aware of when using SDL on Mac OS X:
+
+- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
+  SDL will not register its own. This means that SDL will not terminate using
+  SDL_Quit if it receives a termination request, it will terminate like a 
+  normal app, and it will not send a SDL_DROPFILE when you request to open a
+  file with the app. To solve these issues, put the following code in your 
+  NSApplicationDelegate implementation:
+
+  - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+  {
+      if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
+          SDL_Event event;
+          event.type = SDL_QUIT;
+          SDL_PushEvent(&event);
+      }
+
+      return NSTerminateCancel;
+  }
+
+  - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+  {
+      if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
+          SDL_Event event;
+          event.type = SDL_DROPFILE;
+          event.drop.file = SDL_strdup([filename UTF8String]);
+          return (SDL_PushEvent(&event) > 0);
+      }
+
+      return NO;
+  }
+
+==============================================================================
 Using the Simple DirectMedia Layer with a traditional Makefile
 ==============================================================================