Inherits from: NSResponder : NSObject
Package: com.apple.yellow.application
keyWindow | Returns an NSWindow representing the key window. |
mainMenu | Returns an NSWindow representing the main window. |
registerServicesMenuTypes | Specifies which services are valid for this application. |
runModalForWindow | Runs a modal event loop for the specified NSWindow. |
The NSApplication class provides the central framework for
your application's execution. Every application must have exactly
one instance of NSApplication (or a subclass of NSApplication).
Your program's main()
function
should create this instance by invoking the sharedApplication class method. After
creating the NSApplication object, the main()
function
should load your application's main nib file and then start the
event loop by sending the NSApplication object a run message. If
you create an Application project in Project Builder, this main()
function
is created for you. The main()
function
Project Builder creates begins by calling a function named NSApplicationMain()
,
which is functionally similar to the following:
void NSApplicationMain(int argc, char *argv[]) { [NSApplication sharedApplication]; [NSBundle loadNibNamed:@"myMain" owner:app]; [NSApp run]; }
The sharedApplication class
method initializes the PostScript environment and connects your
program to the Window Server and the Display PostScript server.
The NSApplication object maintains a list of all the NSWindows the application
uses, so it can retrieve any of the application's NSViews. sharedApplication also
initializes the global variable NSApp
,
which you use to retrieve the NSApplication instance. sharedApplication only
performs the initialization once; if you invoke it more than once,
it simply returns the NSApplication object it created previously.
NSApplication's main purpose is to receive events from the
Window Server and distribute them to the proper NSResponders. NSApp
translates
an event into an NSEvent object, then forwards the NSEvent to the
affected NSWindow object. All keyboard and mouse events go directly
to the NSWindow associated with the event. The only exception to
this rule is if the Command key is pressed when a key-down event
occurs; in this case, every NSWindow has an opportunity to respond
to the event. When an NSWindow receives an NSEvent from NSApp
,
it distributes it to the objects in its view hierarchy.
The NSApplication class sets up autorelease pools (instances
of the NSAutoreleasePool class) during initialization and inside
the event loop-specifically, within its init (or sharedApplication)
and run methods. Similarly,
the methods the Application Kit adds to NSBundle employ autorelease pools
during the loading of nib files. These autorelease pools aren't
accessible outside the scope of the respective NSApplication and
NSBundle methods. Typically, an application creates objects either
while the event loop is running or by loading objects from nib files,
so this usually isn't a problem. However, if you do need to use
OpenStep classes within the main()
function
itself (other than to load nib files or to instantiate NSApplication),
you should create an autorelease pool before using the classes and
then release the pool when you're done. For more information,
see the NSAutoreleasePool class specification in the Foundation Framework
Reference.
Rarely do you need to create a custom NSApplication subclass.
In general, a better design is to separate the code that embodies
your program's functionality into a number of custom objects.
Usually, those custom objects are subclasses of NSObject. Methods
defined in your custom objects can be invoked from a small dispatcher
object without being closely tied to NSApp
.
The only reason to subclass NSApplication is if you need to provide
your own special response to messages that are routinely sent to NSApp
.
(Even then, NSApp
's delegate is
often given a chance to respond to such messages, so it's more
appropriate to implement the delegate methods.) To use a custom
subclass of NSApplication, simply send sharedApplication to
your custom class rather than directly to NSApplication. If you
create your application in Project Builder, set the application
class on the Project Attributes inspector, and Project Builder will
update the main()
function accordingly.
As mentioned previously, NSApp
uses
autorelease pools in its init and run methods;
if you override these methods, you'll need to create your own autorelease
pools.
You can assign a delegate to NSApp
.
The delegate responds to certain messages on behalf of NSApp
.
Some of these messages, such as applicationOpenFile, ask the delegate
to perform an action. Another message, applicationShouldTerminate, lets
the delegate determine whether the application should be allowed
to quit. The NSApplication class sends these messages directly to
its delegate.
NSApp
also posts notifications
to the application's default notification center. Any object may
register to receive one or more of the notifications posted by NSApp
by sending
the message addObserver:selector:name:object: to
the default notification center (an instance of the NSNotificationCenter
class). NSApp
's delegate is automatically
registered to receive these notifications if it implements certain
delegate methods. For example, NSApp
posts
notifications when it is about to be done launching the application
and when it is done launching the application (NSApplicationWillFinishLaunchingNotification
and NSApplicationDidFinishLaunchingNotification). The delegate has
an opportunity to respond to these notifications by implementing
the methods applicationWillFinishLaunching and applicationDidFinishLaunching.
If the delegate wants to be informed of both events, it implements
both methods. If it only needs to know when the application is finished
launching, it implements only applicationDidFinishLaunching.
For more information on notifications, see the NSNotificationCenter
class specification in the Foundation Framework Reference.
These are possible return values for runModalForWindow and runModalSession:
Constant | Description |
RunStoppedResponse |
Modal session was broken with stopModal |
RunAbortedResponse |
Modal session was broken with abortModal |
RunContinuesResponse |
Modal session is continuing (returned by runModalSession only) |
- Creating and initializing an NSApplication
- sharedApplication
- finishLaunching
- Changing the active application
- activateIgnoringOtherApps
- isActive
- deactivate
- Running the event loop
- run
- isRunning
- stop
- runModalForWindow
- stopModal
- stopModalWithCode
- abortModal
- beginModalSessionForWindow
- runModalSession
- endModalSession
- sendEvent
- Getting, removing, and posting events
- currentEvent
- nextEventMatchingMask
- discardEventsMatchingMask
- postEvent
- Managing windows
- keyWindow
- mainWindow
- windowWithWindowNumber
- windows
- makeWindowsPerform
- setWindowsNeedUpdate
- updateWindows
- miniaturizeAll
- preventWindowOrdering
- Hiding all windows
- hide
- isHidden
- unhide
- unhideWithoutActivation
- Setting the application's icon
- setApplicationIconImage
- applicationIconImage
- Getting the main menu
- setMainMenu
- mainMenu
- Managing the Window menu
- setWindowsMenu
- windowsMenu
- arrangeInFront
- addWindowsItem
- changeWindowsItem
- removeWindowsItem
- updateWindowsItem
- Managing the Services menu
- setServicesMenu
- servicesMenu
- registerServicesMenuTypes
- validRequestorForTypes
- setServicesProvider
- servicesProvider
- Showing standard panels
- orderFrontColorPanel
- runPageLayout
- Displaying help
- showHelp
- activateContextHelpMode
- Sending action messages
- sendActionToTargetFromSender
- tryToPerform
- targetForAction
- Getting the Display PostScript context
- context
- Reporting an exception
- reportException
- Terminating the application
- terminate
- Assigning a delegate
- setDelegate
- delegate
public static void beep()
As part
of its implmentation, this method calls the function NSBeep
.
public static boolean loadNibFromBundle(NSBundle aBundle, String fileName, Object owner)
true
upon
success, or false
if the specified
nib file couldn't be loadedpublic static boolean loadNibNamed(String aNibName, Object owner)
true
upon
success, or false
if the specified
nib file couldn't be loaded+ (NSApplication *)sharedApplication
NSApp
), creating
it if it doesn't exist yet. This method also
makes a connection to the Window Server and completes other initialization.
Your program should invoke this method as one of the first statements
in main()
; this is done
for you if you create your application with Project Builder. To
retrieve the NSApplication instance after it has been created, use
the global variable NSApp
or invoke
this method. public void abortModal()
RunAbortedResponse
. abortModal is
typically sent by objects registered with the default NSRunLoop;
for example, by objects that have registered a method to be repeatedly
invoked by the NSRunLoop through the use of an NSTimer object. This method can also abort a modal session created by beginModalSessionForWindow, provided the loop that runs the modal session (by invoking runModalSession) catches the exception.
See Also: endModalSession, stopModal, stopModalWithCode
public void activateContextHelpMode(Object sender)
On Mach platforms, most applications don't use this method. Instead, applications enter context-sensitive mode when the user presses the Help key. On either platform, applications exit context-sensitive help mode upon the first event after a help window is displayed.
See Also: showHelp
public void activateIgnoringOtherApps(boolean flag)
false
,
the application is activated only if no other application is currently
active. If flag is true
,
the application activates regardless. On Mach platforms, flag is
normally set to false
. When the Workspace Manager
launches an application, using a value of false
for flag allows
the application to become active if the user waits for it to launch,
but the application remains unobtrusive if the user activates another
application. Regardless of the setting of flag,
there may be a time lag before the application activates-you should
not assume the application will be active immediately after sending
this message.
On Microsoft Windows platforms, flag is
normally set to true
. Setting flag to false
has
no effect.
You rarely need to invoke this method. Under most circumstances, the Application Kit takes care of proper activation. However, you might find this method useful if you implement your own methods for interapplication communication.
You don't need to send this message to make one of the application's NSWindows key. When you send a makeKeyWindow message to an NSWindow, you ensure the NSWindow will be the key window when the application is active.
See Also: deactivate, isActive
public void addWindowsItem(NSWindow aWindow, String aString, boolean isFilename)
false
, aString appears
literally in the menu. If isFilename is true
, aString is assumed
to be a converted path name with the name of the file preceding
the path (the way NSWindow's setTitleWithRepresentedFilename: method
shows a title). If an item for aWindow already
exists in the Window menu, this method has no effect. You rarely
invoke this method because an item is placed in the Window menu
for you whenever an NSWindow's title is set.See Also: changeWindowsItem, - setTitle:, - setTitle: (NSWindow)
public NSImage applicationIconImage()
See Also: setApplicationIconImage
public void arrangeInFront(java.lang.Object sender)
See Also: addWindowsItem, removeWindowsItem, - makeKeyAndOrderFront:(NSWindow)
public NSModalSession beginModalSessionForWindow(NSWindow aWindow)
beginModalSessionForWindow only
sets up the modal session. To actually run the session, use runModalSession. beginModalSessionForWindow should
be balanced by endModalSession.
Make sure these two messages are sent within the same exception
handling scope. That is, if you send beginModalSessionForWindow inside
an NS_DURING
construct,
you must send endModalSession before NS_ENDHANDLER
.
If
an exception is raised, beginModalSessionForWindow arranges
for proper cleanup. Do not use NS_DURING
constructs
to send an endModalSession message in the
event of an exception.
A loop using these methods is similar to a modal event loop run with runModalForWindow, except the application can continue processing between method invocations.
public void changeWindowsItem(NSWindow aWindow, String aString, boolean isFilename)
false
, aString appears
literally in the menu. If isFilename is true
, aString is
assumed to be a converted path name with the file's name preceding
the path (the way NSWindow's setTitleWithRepresentedFilename: places
a title). See Also: addWindowsItem, removeWindowsItem, - setTitle:(NSWindow)
public NSDPSContext context()
public NSEvent currentEvent()
NSApp
receives
events and forwards the current event to the affected NSWindow object,
which then distributes it to the objects in its view hierarchy. See Also: discardEventsMatchingMask, postEvent, sendEvent
public void deactivate()
See Also: activateIgnoringOtherApps
public Object delegate()
- (id)delegate
See Also: setDelegate
public void discardEventsMatchingMask(int mask, NSEvent lastEvent)
NSApp
. mask can contain these constants:
LeftMouseDownMask
LeftMouseUpMask
RightMouseDownMask
RightMouseUpMask
MouseMovedMask
LeftMouseDraggedMask
RightMouseDraggedMask
MouseEnteredMask
MouseExitedMask
KeyDownMask
KeyUpMask
FlagsChangedMask
PeriodicMask
CursorUpdateMask
AnyEventMask
Use
this method to ignore events that occur before a particular kind
of event. For example, suppose your application has a tracking loop
that you exit when the user releases the mouse button, and you want
to discard all events that occurred during that loop. You use AnyEventMask
as
the mask argument and pass the mouse up event as the lastEvent argument.
Passing the mouse-up event as lastEvent ensures
that any events that might have occurred after the mouse-up event
(that is, that appear in the queue after the mouse-up event) don't
get discarded.
See Also: nextEventMatchingMask
public void endModalSession(NSModalSession session)
See Also: runModalSession
public void finishLaunching()
See Also: applicationWillFinishLaunching, applicationDidFinishLaunching
public void hide(Object sender)
See Also: miniaturizeAll, unhide, unhideWithoutActivation, applicationDidHide, applicationWillHide
public boolean isActive()
true
if
this is the active application, false
otherwise.See Also: activateIgnoringOtherApps, deactivate
public boolean isHidden()
true
if
the application is hidden, false
otherwise.See Also: hide, unhide, unhideWithoutActivation
public boolean isRunning()
true
if
the main event loop is running, false
otherwise. false
means
the stop method was
invoked. public NSWindow keyWindow()
null
if there is no key window,
if the application's nib file hasn't finished loading yet, or
if the key window belongs to another application. See Also: mainWindow, - isKeyWindow(NSWindow)
public NSMenu mainMenu()
See Also: setMainMenu
public NSWindow mainWindow()
null
if there is no
main window, if the application's nib file hasn't finished loading,
if the main window belongs to another application, or if the application
is hidden.See Also: keyWindow, - isMainWindow(NSWindow)
public NSWindow makeWindowsPerform(NSSelector aSelector, boolean flag)
null
. Returns
that NSWindow, or null
if all NSWindows
returned null
for aSelector. If flag is true
,
the NSWindows receive the aSelector message
in the front-to-back order in which they appear in the Window Server's
window list. If flag is false
,
NSWindows receive the message in the order they appear in NSApp
's
window list. This order is unspecified.
The method designated by aSelector can't take any arguments.
See Also: sendActionToTargetFromSender, tryToPerform, windows
public void miniaturizeAll(Object sender)
See Also: hide
public NSWindow modalWindow()
null
.public NSEvent nextEventMatchingMask(int mask, NSDate expiration, String mode, boolean flag)
null
if no such event
is found before the expiration date. If flag is true
,
the event is removed from the queue. See the method description
for discardEventsMatchingMask for
a list of the possible values for mask.LeftMouseDownMask
LeftMouseUpMask
RightMouseDownMask
RightMouseUpMask
MouseMovedMask
LeftMouseDraggedMask
RightMouseDraggedMask
MouseEnteredMask
MouseExitedMask
KeyDownMask
KeyUpMask
FlagsChangedMask
PeriodicMask
CursorUpdateMask
AnyEventMask
The mode argument
names an NSRunLoop mode that determines what other ports are listened
to and what timers may fire while NSApp
is
waiting for the event. The possible modes available in the Application
Kit are:
DefaultRunLoopMode
EventTrackingRunLoopMode
ModalPanelRunLoopMode
ConnectionReplyMode
Events that are skipped are left in the queue.
You can use this method to short circuit normal event dispatching and get your own events. For example, you may want to do this in response to a mouse-down event in order to track the mouse while it's down. In this case, you would set mask to accept mouse-dragged or mouse-up events and use the EventTrackingRunLoopMode.
See Also: postEvent, run, runModalForWindow
public void orderFrontColorPanel(java.lang.Object anObject)
public void orderFrontStandardAboutPanel(Object sender)
null
argument. See orderFrontStandardAboutPanelWithOptions for
a description of what's displayed. public void orderFrontStandardAboutPanelWithOptions (NSDictionary optionsDictionary)
The following are keys that can occur in optionsDictionary:
NSProcessInfo.processInfo().processName()
.See Also: orderFrontStandardAboutPanel
public void postEvent(NSEvent aNSEvent, boolean aBoolean)
true
,
the event is added to the front of the queue, otherwise the event
is added to the back of the queue. See Also: currentEvent, sendEvent
public void preventWindowOrdering()
public void registerServicesMenuTypes(NSArray sendTypes, NSArray returnTypes)
NSApp
. See Also: validRequestorForTypes, - readSelectionFromPasteboard: (NSServicesRequests protocol) - writeSelectionToPasteboard:types: (NSServicesRequests protocol)
public void removeWindowsItem(NSWindow aWindow)
See Also: addWindowsItem, changeWindowsItem
public void reportException(Throwable anException)
NSLog()
. This
method does not raise the exception. Use it inside of an exception
handler to record that the exception occurred.public void run()
NSApp
using sendEvent. Send
a run message as the last statement from main()
,
after the application's objects have been initialized.
See Also: runModalForWindow, runModalSession, applicationDidFinishLaunching
public int runModalForWindow(NSWindow aWindow)
RunStoppedResponse
.
If abortModal is used, it returns the constant RunAbortedResponse
. This
method is functionally similar to the following:NSModalSession session = [NSApp beginModalSessionForWindow:theWindow]; for (;;) { if ([NSApp runModalSession:session] != NSRunContinuesResponse) break; } [NSApp endModalSession:session];
The window aWindow is placed on the screen and made key as a result of the runModalForWindow message. Do not send makeKeyAndOrderFront: to aWindow.
See Also: run, runModalSession
public int runModalSession(NSModalSession session)
If
the modal session was not stopped, this method returns RunContinuesResponse
.
If stopModalwas invoked
as the result of event processing, RunStoppedResponse
is
returned. If stopModalWithCode was invoked,
this method returns the value passed to stopModalWithCode. The exception raised
by abortModal isn't
caught, so abortModal will not stop the loop.
The window is placed on the screen and made key as a result of the runModalSession message. Do not send a separate makeKeyAndOrderFront: message.
See Also: endModalSession, run
public void runPageLayout(Object sender)
public boolean sendActionToTargetFromSender(NSSelector anAction, Object aTarget, Object sender)
null
, NSApp
looks for
an object that can respond to the message-that is, an object that
implements a method matching anAction.
It begins with the first responder of the key window. If the first
responder can't respond, it tries the first responder's next
responder and continues following next responder links up the responder
chain. If none of the objects in the key window's responder chain
can handle the message, NSApp
attempts
to send the message to the key window's delegate.If the
delegate doesn't respond and the main window is different from
the key window, NSApp
begins again
with the first responder in the main window. If objects in the main
window can't respond, NSApp
attempts
to send the message to the main window's delegate. If still no
object has responded, NSApp
tries
to handle the message itself. If NSApp
can't
respond, it attempts to send the message to its own delegate.
Returns true
if
the action is successfully sent, otherwise returns false
.
See Also: targetForAction, tryToPerform, makeWindowsPerform
public void sendEvent(NSEvent anEvent)
See Also: currentEvent, postEvent
public NSMenu servicesMenu()
null
if no Services
menu has been created.See Also: setServicesMenu
public Object servicesProvider()
See Also: setServicesProvider
public void setApplicationIconImage(NSImage anImage)
See Also: applicationIconImage
public void setDelegate(Object anObject)
See Also: delegate
public void setMainMenu(NSMenu aMenu)
See Also: mainMenu
public void setServicesMenu(NSMenu aMenu)
See Also: servicesMenu
public void setServicesProvider(Object aProvider)
For more information on registering services, see the on-line document /System/Documentation/Developer/YellowBox/TasksAndConcepts/ProgrammingTopics/Services.pdf.
See Also: servicesProvider
public void setWindowsMenu(NSMenu aMenu)
See Also: windowsMenu
public void setWindowsNeedUpdate(boolean flag)
See Also: updateWindows
public void showHelp(Object sender)
On Microsoft Windows platforms, the help file is typically an HLP file, so this method brings up Microsoft Windows help. On Mach platforms, the help file is typically an RTF file and is displayed using Edit, but the help file can be anything. For example, Project Builder on Mach brings up a Digital Librarian bookshelf in response to its Help command.
For more information on providing on-line help for your application, see the NSHelpManager class specification.
See Also: activateContextHelpMode
public void stop(Object anObject)
main()
function.
A subsequent run message will restart the
loop.If this method is invoked during a modal event loop, it will break that loop but not the main event loop.
See Also: runModalForWindow, runModalSession, terminate
public void stopModal()
RunStoppedResponse
. This
method will stop the loop only if it's executed by code responding
to an event. If you need to stop a runModalForWindow loop
from a method registered with the current RunLoop (for example,
a method repeatedly invoked by an Timer object), use the abortModal method. See Also: runModalSession, stopModalWithCode
public void stopModalWithCode(int returnCode)
See Also: abortModal
public Object targetForAction(NSSelector aSelector)
See Also: sendActionToTargetFromSender, tryToPerform
public Object targetForActionToFrom(NSSelector aNSSelector, Object anObject, Object anObject)
public void terminate(Object sender)
false
,
control is returned to the main event loop, and the application
isn't terminated. Otherwise, this method posts an NSApplicationWillTerminateNotification
to the default notification center. Don't put final cleanup code
in your application's main()
function-it
will never be executed. If cleanup is necessary, have the delegate
respond to applicationWillTerminate and
perform cleanup in that method. public boolean tryToPerform(NSSelector aSelector, Object anObject)
true
. Otherwise,
it returns false
.See Also: - respondsToSelector: (NSObject)
public void unhide(Object sender)
See Also: activateIgnoringOtherApps, hide
public void unhideWithoutActivation()
See Also: activateIgnoringOtherApps, hide, applicationDidUnhide, applicationWillUnhide
public void updateWindows()
When this method begins, it posts an NSApplicationWillUpdateNotification to the default notification center. When it successfully completes, it posts an NSApplicationDidUpdateNotification.
See Also: setWindowsNeedUpdate, applicationDidUpdate, applicationWillUpdate
public void updateWindowsItem(NSWindow aWindow)
See Also: changeWindowsItem, - setDocumentEdited:(NSWindow)
public Object validRequestorForTypes(String sendType, String returnType)
NSApp
is typically
the last item in the responder chain, so it usually only receives
this message if none of the current responders can send sendType data
and accept back returnType data. The
receiver passes this message on to its delegate if the delegate
can respond (and isn't an NSResponder with its own next responder).
If the delegate can't respond or returns null
,
this method returns null
.
If the delegate can find an object that can send sendType data
and accept back returnType data,
that object is returned.
See Also: registerServicesMenuTypes, - validRequestorForSendType:returnType:(NSResponder), - readSelectionFromPasteboard: (NSServicesRequests protocol) - writeSelectionToPasteboard:types: (NSServicesRequests protocol)
public NSArray windows()
public NSMenu windowsMenu()
null
if
no Window menu has been created.See Also: setWindowsMenu
public NSWindow windowWithWindowNumber(int windowNum)
public abstract boolean applicationOpenFile(NSApplication theApplication, String filename)
true
if the file is successfully
opened, and false
otherwise. If the
user started up the application by double-clicking a file, the delegate
receives the applicationOpenFile message
before receiving applicationDidFinishLaunching.
( applicationWillFinishLaunching is sent
before applicationOpenFile.)See Also: applicationOpenFileWithoutUI, applicationOpenTempFile, applicationOpenUntitledFile
public abstract boolean applicationOpenFileWithoutUI (Object sender, String filename)
true
if
the file was successfully opened, false
otherwise. See Also: applicationOpenFile, applicationOpenTempFile, applicationOpenUntitledFile, applicationPrintFile
public abstract boolean applicationOpenTempFile (NSApplication theApplication, String filename)
true
if the file is successfully
opened, and false
otherwise.By design, a file opened through this method is assumed to be temporary-it's the application's responsibility to remove the file at the appropriate time.
See Also: applicationOpenFile, applicationOpenFileWithoutUI, applicationOpenUntitledFile
public abstract boolean applicationPrintFile (NSApplication theApplication, String filename)
-NSPrint
option.
Sent directly by theApplication to
the delegate. The method should attempt to print the file filename,
returning true
if the file was successfully
printed, and false
otherwise. The
application terminates (using the terminate method) after this method
returns.
If at all possible, this method should print
the file without displaying the user interface. For example, if
you pass the -NSPrint
option
to the TextEdit application, TextEdit assumes you want to print
the entire contents of the specified file. However, if the application
opens more complex documents, you may want to display a panel that
lets the user choose exactly what they want to print.
See Also: applicationOpenFileWithoutUI
public abstract void applicationDidBecomeActive (NSNotification aNotification)
See Also: applicationDidFinishLaunching, applicationDidResignActive, applicationWillBecomeActive
public abstract void applicationDidFinishLaunching (NSNotification aNotification)
See Also: finishLaunching, applicationDidBecomeActive
public abstract void applicationDidHide (NSNotification aNotification)
See Also: applicationWillHide, applicationDidUnhide, hide
public abstract void applicationDidResignActive (NSNotification aNotification)
See Also: applicationDidBecomeActive, applicationWillResignActive
public abstract void applicationDidUnhide (NSNotification aNotification)
See Also: applicationDidHide, applicationWillUnhide, unhide
public abstract void applicationDidUpdate (NSNotification aNotification)
See Also: applicationWillUpdate, updateWindows
public abstract boolean applicationOpenUntitledFile (NSApplication theApplication)
true
if
the file was successfully opened, false
otherwise. See Also: applicationOpenFile, applicationOpenFileWithoutUI, applicationOpenTempFile
public abstract boolean applicationShouldOpenUntitledFile (NSApplication sender)
(BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
false
to prevent the
application from opening an untitled file; return true
,
otherwise. Note that applicationOpenUntitledFile is
invoked if this method returns true
.public abstract boolean applicationShouldTerminate (NSApplication sender)
false
,
the application is not terminated, and control returns to the main
event loop. Return true
to allow
the application to terminate.See Also: terminate, applicationShouldTerminateAfterLastWindowClosed, applicationWillTerminate
public abstract boolean applicationShouldTerminateAfterLastWindowClosed (NSApplication theApplication)
This method is intended for the Microsoft Windows platform. On Microsoft Windows, the default behavior is to terminate the application if the user closes the last window. Most applications use this default behavior; however, you may choose to have applicationShouldTerminateAfterLastWindowClosed: perform some other function, such as display a panel that gives the user a choice of exiting the application or opening a new window.
If
this method returns false
, the application
is not terminated, and control returns to the main event loop. Return true
to
allow the application to terminate. Note that applicationShouldTerminate is invoked
if this method returns true
.
See Also: terminate
public abstract void applicationWillBecomeActive (NSNotification aNotification)
See Also: applicationDidBecomeActive, applicationWillFinishLaunching, applicationWillResignActive
public abstract void applicationWillFinishLaunching (NSNotification aNotification)
See Also: applicationDidFinishLaunching, applicationWillBecomeActive, finishLaunching
public abstract void applicationWillHide (NSNotification aNotification)
See Also: applicationDidHide, hide
public abstract void applicationWillTerminate (NSNotification aNotification)
See Also: applicationShouldTerminate, terminate
public abstract void applicationWillResignActive (NSNotification aNotification)
See Also: applicationWillBecomeActive, applicationDidResignActive
public abstract void applicationWillUnhide (NSNotification aNotification)
See Also: unhide, applicationDidUnhide, applicationWillHide
public abstract void applicationWillUpdate (NSNotification aNotification)
See Also: applicationDidUpdate, updateWindows
Posted immediately after the application becomes active. This
notification contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the end of the finishLaunching method to indicate
that the application has completed launching and is ready to run.
This notification contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the end of the hide method to indicate that the
application is now hidden. This notification contains a notification
object but no userInfo dictionary.
The notification object is NSApp
.
Posted immediately after the application gives up its active
status to another application. This notification contains a notification
object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the end of the unhideWithoutActivation method to
indicate that the application is now visible. This notification
contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the end of the updateWindows method to indicate
that the application has finished updating its windows. This notification
contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted immediately after the application becomes active. This
notification contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the start of the finishLaunching method to indicate
that the application has completed its initialization process and
is about to finish launching. This notification contains a notification
object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the start of the hide method to indicate that the
application is about to be hidden. This notification contains a
notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted immediately before the application gives up its active
status to another application. This notification contains a notification
object but no userInfo dictionary.
The notification object is NSApp
.
Posted by the terminate method
to indicate that the application will terminate. Posted only if
the delegate method applicationShouldTerminate returns true
.
This notification contains a notification object but no userInfo dictionary. The
notification object is NSApp
.
Posted at the start of the unhideWithoutActivation method to
indicate that the application is about to be visible. This notification
contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
Posted at the start of the updateWindows method to indicate
that the application is about to update its windows. This notification
contains a notification object but no userInfo dictionary.
The notification object is NSApp
.