[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: close application from title bar control - close
From: |
Vaisburd, Haim |
Subject: |
RE: close application from title bar control - close |
Date: |
Wed, 13 Sep 2006 12:19:59 -0700 |
> Richard Frith-Macdonald wrote:
> > On 13 Sep 2006, at 12:14, pradip patel wrote:
> > How can I close whole application from title bar controls- close
> > button
> Applications are not supposed to terminate when the window closes ...
The easiest way is probably to implement the method
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (id)sender
in the delegate.
1. Create your own application delegate class and attach the
delegate object to the application object if you haven't
done this yet.
For example, my main() is literally this:
int main (int argc, const char **argv)
{
NSAutoreleasePool * pool = [NSAutoreleasePool new];
[NSApplication sharedApplication];
[NSApp setDelegate: [AppController new]]; // AppController is your
own
return NSApplicationMain(argc, argv);
}
2. Add the following method to AppController class
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (id)sender
{
return YES;
}
--Tima