Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSApplicationDelegateMBS class.

NSApplicationDelegateMBS.applicationDidBecomeActive(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately after the application becomes active.

Some examples using this event:

NSApplicationDelegateMBS.applicationDidChangeScreenParameters(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center when the configuration of the displays attached to the computer is changed (either programmatically or when the user changes settings in the Displays control panel).

NSApplicationDelegateMBS.applicationDidDecodeRestorableState(coder as NSCoderMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
This event gives you the chance to restore your own state.

Some examples using this event:

NSApplicationDelegateMBS.applicationDidFinishLaunching(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center after the application has been launched and initialized but before it has received its first event.

Delegates can implement this method to perform further initialization. This method is called after the application's main run loop has been started but before it has processed any events. If the application was launched by the user opening a file, the delegate's applicationOpenFile method is called before this method. If you want to perform initialization before any files are opened, implement the applicationWillFinishLaunching method in your delegate, which is called before applicationOpenFile.)

Some examples using this event:

NSApplicationDelegateMBS.applicationDidHide(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately after the application is hidden.

Some examples using this event:

NSApplicationDelegateMBS.applicationDidResignActive(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately after the application is deactivated.

NSApplicationDelegateMBS.applicationDidUnhide(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately after the application is made visible.

Some examples using this event:

NSApplicationDelegateMBS.applicationDidUpdate(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately after the application object updates its windows.

NSApplicationDelegateMBS.applicationDockMenu as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Allows the delegate to supply a dock menu for the application dynamically.

Return the menu to display in the dock. Or nil for having no/default menu.

Some examples using this event:

NSApplicationDelegateMBS.applicationOpenFile(filename as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Tells the delegate to open a single file.

filename: The path of the file to open.

Return yes if the file was successfully opened or false if it was not.

Sent directly by application to the delegate. The method should open the file filename, returning 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.)

If you return false, the plugin will pass the event to the default Xojo runtime application delegate, so the OpenDocument event can fire.

NSApplicationDelegateMBS.applicationOpenFiles(filenames() as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Tells the delegate to open multiple files.

sender: The application object associated with the delegate.
filenames: An array of strings containing the names of the files to open..

Identical to applicationOpenFile except that the receiver opens multiple files corresponding to the file names in the filenames array. Delegates should invoke the replyToOpenOrPrint method upon success or failure, or when the user cancels the operation.

If you add code to this event, it is possible that OpenDocument event in Xojo does not fire.

NSApplicationDelegateMBS.applicationOpenFileWithoutUI(filename as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Tells the delegate to open a file programmatically.

filename: The name of the file to open.

Return true if the file was successfully opened or false if it was not.

Sent directly by sender to the delegate to request that the file filename be opened as a linked file. The method should open the file without bringing up its application's user interface—that is, work with the file is under programmatic control of sender, rather than under keyboard control of the user.

If you add code to this event, it is possible that OpenDocument event in Xojo does not fire.

NSApplicationDelegateMBS.applicationOpenTempFile(filename as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Tells the delegate to open a temporary file.

filename: The name of the temporary file to open.

True if the file was successfully opened or false if it was not.

Sent directly by application to the delegate. The method should attempt to open the file filename, returning 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.

If you add code to this event, it is possible that OpenDocument event in Xojo does not fire.

NSApplicationDelegateMBS.applicationOpenUntitledFile as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Tells the delegate to open an untitled file.

Return true if the file was successfully opened or false if it was not.
Sent directly by application to the delegate to request that a new, untitled file be opened.

If you return false, the plugin will pass the event to the default Xojo runtime application delegate.

If you add code to this event, it is possible that OpenDocument event in Xojo does not fire.

NSApplicationDelegateMBS.applicationPrintFile(filename as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent when the user starts up the application on the command line with the -NSPrint option.

filename: The name of the file to print.

Returns true if the file was successfully printed or false if it was not.

This message is sent directly by application to the delegate. 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.

NSApplicationDelegateMBS.applicationPrintFiles(fileNames() as string, printSettings as dictionary, showPrintPanels as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Prints a group of files.

fileNames: An array of strings, each of which contains the name of a file to print.

printSettings: A dictionary containing NSPrintInfo-compatible print job attributes.

showPrintPanels: A Boolean that specifies whether the print panel should be displayed for each file printed. Print progress indicators will be presented even if this value is false.

Return a constant indicating whether printing was successful. For a list of possible values, see NSPrinting* constants.

Return NSPrintingReplyLater if the result of printing cannot be returned immediately, for example, if printing will cause the presentation of a sheet. If your method returns NSPrintingReplyLater it must always invoke the NSApplicationMBS method replyToOpenOrPrint when the entire print operation has been completed, successfully or not.

NSApplicationDelegateMBS.applicationShouldHandleReopen(hasVisibleWindows as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the application to the delegate prior to default behavior to reopen (rapp) AppleEvents.

flag: Indicates whether the NSApplication object found any visible windows in your application. You can use this value as an indication of whether the application would do anything if you return true.

Return true if you want the application to perform its normal tasks or false if you want the application to do nothing.

These events are sent whenever the Finder reactivates an already running application because someone double-clicked it again or used the dock to activate it.

By default the Application Kit will handle this event by checking whether there are any visible NSWindow (not NSPanel) objects, and, if there are none, it goes through the standard untitled document creation (the same as it does if application is launched without any document to open). For most document-based applications, an untitled document will be created.

The application delegate will also get a chance to respond to the normal untitled document delegate methods. If you implement this method in your application delegate, it will be called before any of the default behavior happens. If you return true, then NSApplication will proceed as normal. If you return false, then NSApplication will do nothing. So, you can either implement this method with a version that does nothing, and return false if you do not want anything to happen at all (not recommended), or you can implement this method, handle the event yourself in some custom way, and return false.

Miniaturized windows, windows in the Dock, are considered visible by this method, and cause flag to return true, despite the fact that miniaturized windows return false when sent an isVisible message.

Having no code in the event will tell the plugin to return true.

NSApplicationDelegateMBS.applicationShouldOpenUntitledFile as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Invoked immediately before opening an untitled file.

Return true if the application should open a new untitled file or false if it should not.

Use this method to decide whether the application should open a new, untitled file. Note that applicationOpenUntitledFile is invoked if this method returns true.

If you return false here, the NewDocument event in Xojo may not fire.
Having no code in this event is the same as returning true.

NSApplicationDelegateMBS.applicationShouldTerminate as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent to notify the delegate that the application is about to terminate..

One of the values defined in NSTerminate* constants indicating whether the application should terminate.

This method is called after the application's Quit menu item has been selected, or after the terminate method has been called. Generally, you should return NSTerminateNow to allow the termination to complete, but you can cancel the termination process or delay it somewhat as needed. For example, you might delay termination to finish processing some critical data but then terminate the application as soon as you are done by calling the replyToApplicationShouldTerminate method.

NSApplicationDelegateMBS.applicationShouldTerminateAfterLastWindowClosed as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Invoked when the user closes the last window the application has open.

Return false if the application should not be terminated when its last window is closed; otherwise, true to terminate the application.

The application sends this message to your delegate when the application's last window is closed. It sends this message regardless of whether there are still panels open. (A panel in this case is defined as being an instance of NSPanel or one of its subclasses.)

If your implementation returns false, control returns to the main event loop and the application is not terminated. If you return true, your delegate's applicationShouldTerminate method is subsequently invoked to confirm that the application should be terminated.

Having no code in this event is the same as returning false.

NSApplicationDelegateMBS.applicationWillBecomeActive(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately before the application becomes active.

Some examples using this event:

NSApplicationDelegateMBS.applicationWillEncodeRestorableState(coder as NSCoderMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Event called to give you chance to encode any additional state into the NSCoder.

If the restorable state managed by the delegate changes, you must call NSApplicationMBS.invalidateRestorableState so that it will be re-encoded.

Some examples using this event:

NSApplicationDelegateMBS.applicationWillFinishLaunching(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately before the application object is initialized.

NSApplicationDelegateMBS.applicationWillHide(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately before the application is hidden.

NSApplicationDelegateMBS.applicationWillPresentError(error as NSErrorMBS) as NSErrorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent to the delegate before the specified application presents an error message to the user.

error: The error object that is used to construct the error message. Your implementation of this method can return a new NSError object or the same one in this parameter.

Return the error object to display.

You can implement this delegate method to customize the presentation of any error presented by your application, as long as no code in your application overrides either of the NSResponder methods presentError in a way that prevents errors from being passed down the responder chain to the application object.

Your implementation of this delegate method can examine error and, if its localized description or recovery information is unhelpfully generic, return an error object with specific localized text that is more suitable for presentation in alert sheets and dialogs. If you do this, always use the domain and error code of the NSError object to distinguish between errors whose presentation you want to customize and those you do not. Don't make decisions based on the localized description, recovery suggestion, or recovery options because parsing localized text is problematic. If you decide not to customize the error presentation, just return the passed-in error object.

If you have no code in this event or you return nil, the plugin passes the given error back to the Cocoa runtime.

NSApplicationDelegateMBS.applicationWillResignActive(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately before the application is deactivated.

NSApplicationDelegateMBS.applicationWillTerminate(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately before the application terminates.

Some examples using this event:

NSApplicationDelegateMBS.applicationWillUnhide(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately after the application is unhidden.

Some examples using this event:

NSApplicationDelegateMBS.applicationWillUpdate(Notification as NSNotificationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No
Sent by the default notification center immediately before the application object updates its windows.

NSApplicationDelegateMBS.restoreWindowWithIdentifier(identifier as string, state as NSCoderMBS, byref resultWindow as Variant, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 13.2 ✅ Yes ❌ No ❌ No ❌ No
Invoked to request that a window be restored.

If you plan to use this event, please initialize the NSApplicationDelegateMBS subclass in app.constructor.

identifier: The unique interface item identifier string that was previously associated with the window. Use this string to determine which window to create.
state: A NSCoderMBS object containing the window state information. This coder object contains the combined restorable state of the window, which can include the state of the window, its delegate, window controller, and document object. You can use this state to determine which window to create.

Pass back with the parameters:
The window that was created or nil if the window could not be created.
An error object if the window was not recognized or could not be created for whatever reason; otherwise, specify nil. In OS X 10.7, the error parameter is ignored.

Return true if the window was restored; otherwise false.

If the receiver knows how to restore the identified window, it should invoke the completion handler with the window, possibly creating it. It is acceptable to use a pre-existing window, though you should not pass the same window to more than one completion handler. If the receiver cannot restore the identified window (for example, the window referenced a document that has been deleted), it should invoke the completion handler with a nil window.

The receiver is application is passed the identifier of the window, which allows it to quickly check for known windows. For example, you might give your preferences window an identifier of "preferences" in the nib, and then check for that identifier in your implementation. The receiver is also passed the NSCoder instance containing the combined restorable state of the window, its delegate, the window controller, and any document. The receiver may decode information previously stored in the coder to determine what window to restore.

Available in OS X v10.7 and later.

The plugin implements this method for NSApplication and forwards the message to this event.
If you return true, please set either error or resultWindow values. resultWindow must be an NSWindowMBS or a window object.

Some examples using this event:

NSApplicationDelegateMBS.userDidAcceptCloudKitShareWithMetadata(metadata as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa MBS MacCocoa Plugin 21.2 ✅ Yes ❌ No ❌ No ❌ No
Tells you that the app has access to shared information in CloudKit.
Example
// sample implementation of the event:

Sub userDidAcceptCloudKitShareWithMetadata(metadata as Variant) Handles userDidAcceptCloudKitShareWithMetadata
Dim c As CKShareMetadataMBS = metadata

Message "User did accept CloudKit share: "+c.containerIdentifier
End Sub

metadata is a CKShareMetadataMBS class.

metdata: Information about the CloudKit data that is available to the app. Use this object to retrieve information about the CKShare object and the associated records that are available.

Use this method to respond to a CloudKit Sharing invitation. In your implementation, accept the share by scheduling a CKAcceptSharesOperationMBS object that contains the provided metadata object. After the user accepts the share, you can begin fetching records and incorporating the resulting data into your app.
The system launches the app, as necessary, before calling this method.

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...