Application Quit Event?

Discussion in 'Mac Programming' started by Fritzables, Oct 17, 2011.

  1. Fritzables macrumors regular

    Joined:
    May 6, 2011
    Location:
    Brisbane AUSTRALIA
    #1
    Clicking an application's red close button up in it's top left corner, does this create the same event that is generated by using the Quit Menu option?
     
  2. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    Depends. If your application is a "single window" type, then the answer is yes. If it's document-based, and thus has one window for each open document, then no.
     
  3. Robo6675 macrumors newbie

    Joined:
    Apr 12, 2011
    #3
    99% of the time, clicking the red circle doesn't close an application. When I came from a pc a couple years ago, I was confused by that too
     
  4. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #4
    If you have a single-window type application and want it to shut down if the main window is closed, you can modify your application delegate by adding the following method:

    Code:
    // Stop the application when all windows have closed.
    - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
    {
        return TRUE;
    }
    

    Then the application will quit when the last window closes. The System Preferences app is an example of this behavior.
     
  5. Fritzables thread starter macrumors regular

    Joined:
    May 6, 2011
    Location:
    Brisbane AUSTRALIA
    #5
    Thanks, Yea, it's the parent window I was questioning. On multi-window apps I need to take care of the close event myself.

    Pete
     

Share This Page