README-macosx.txt
changeset 7801 f00cc0a8cd5d
parent 7222 2435b221d77d
child 8191 b50f4ae6d5f2
     1.1 --- a/README-macosx.txt	Thu Oct 10 02:37:36 2013 -0400
     1.2 +++ b/README-macosx.txt	Mon Oct 07 16:01:40 2013 -0700
     1.3 @@ -30,6 +30,42 @@
     1.4  use the traditional autoconf/automake/make method, or use Xcode.
     1.5  
     1.6  ==============================================================================
     1.7 +Caveats for using SDL with Mac OS X
     1.8 +==============================================================================
     1.9 +
    1.10 +Some things you have to be aware of when using SDL on Mac OS X:
    1.11 +
    1.12 +- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
    1.13 +  SDL will not register its own. This means that SDL will not terminate using
    1.14 +  SDL_Quit if it receives a termination request, it will terminate like a 
    1.15 +  normal app, and it will not send a SDL_DROPFILE when you request to open a
    1.16 +  file with the app. To solve these issues, put the following code in your 
    1.17 +  NSApplicationDelegate implementation:
    1.18 +
    1.19 +  - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
    1.20 +  {
    1.21 +      if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
    1.22 +          SDL_Event event;
    1.23 +          event.type = SDL_QUIT;
    1.24 +          SDL_PushEvent(&event);
    1.25 +      }
    1.26 +
    1.27 +      return NSTerminateCancel;
    1.28 +  }
    1.29 +
    1.30 +  - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
    1.31 +  {
    1.32 +      if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
    1.33 +          SDL_Event event;
    1.34 +          event.type = SDL_DROPFILE;
    1.35 +          event.drop.file = SDL_strdup([filename UTF8String]);
    1.36 +          return (SDL_PushEvent(&event) > 0);
    1.37 +      }
    1.38 +
    1.39 +      return NO;
    1.40 +  }
    1.41 +
    1.42 +==============================================================================
    1.43  Using the Simple DirectMedia Layer with a traditional Makefile
    1.44  ==============================================================================
    1.45