pub unsafe trait NSApplicationDelegate: NSObjectProtocol + MainThreadOnly {
Show 43 methods
// Provided methods
fn applicationShouldTerminate(
&self,
sender: &NSApplication,
) -> NSApplicationTerminateReply
where Self: Sized + Message { ... }
fn application_openURLs(
&self,
application: &NSApplication,
urls: &NSArray<NSURL>,
)
where Self: Sized + Message { ... }
fn application_openFile(
&self,
sender: &NSApplication,
filename: &NSString,
) -> bool
where Self: Sized + Message { ... }
fn application_openFiles(
&self,
sender: &NSApplication,
filenames: &NSArray<NSString>,
)
where Self: Sized + Message { ... }
fn application_openTempFile(
&self,
sender: &NSApplication,
filename: &NSString,
) -> bool
where Self: Sized + Message { ... }
fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool
where Self: Sized + Message { ... }
fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool
where Self: Sized + Message { ... }
unsafe fn application_openFileWithoutUI(
&self,
sender: &AnyObject,
filename: &NSString,
) -> bool
where Self: Sized + Message { ... }
fn application_printFile(
&self,
sender: &NSApplication,
filename: &NSString,
) -> bool
where Self: Sized + Message { ... }
unsafe fn application_printFiles_withSettings_showPrintPanels(
&self,
application: &NSApplication,
file_names: &NSArray<NSString>,
print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
show_print_panels: bool,
) -> NSApplicationPrintReply
where Self: Sized + Message { ... }
fn applicationShouldTerminateAfterLastWindowClosed(
&self,
sender: &NSApplication,
) -> bool
where Self: Sized + Message { ... }
fn applicationShouldHandleReopen_hasVisibleWindows(
&self,
sender: &NSApplication,
has_visible_windows: bool,
) -> bool
where Self: Sized + Message { ... }
fn applicationDockMenu(
&self,
sender: &NSApplication,
) -> Option<Retained<NSMenu>>
where Self: Sized + Message { ... }
fn application_willPresentError(
&self,
application: &NSApplication,
error: &NSError,
) -> Retained<NSError>
where Self: Sized + Message { ... }
fn application_didRegisterForRemoteNotificationsWithDeviceToken(
&self,
application: &NSApplication,
device_token: &NSData,
)
where Self: Sized + Message { ... }
fn application_didFailToRegisterForRemoteNotificationsWithError(
&self,
application: &NSApplication,
error: &NSError,
)
where Self: Sized + Message { ... }
unsafe fn application_didReceiveRemoteNotification(
&self,
application: &NSApplication,
user_info: &NSDictionary<NSString, AnyObject>,
)
where Self: Sized + Message { ... }
fn applicationSupportsSecureRestorableState(
&self,
app: &NSApplication,
) -> bool
where Self: Sized + Message { ... }
unsafe fn application_willEncodeRestorableState(
&self,
app: &NSApplication,
coder: &NSCoder,
)
where Self: Sized + Message { ... }
unsafe fn application_didDecodeRestorableState(
&self,
app: &NSApplication,
coder: &NSCoder,
)
where Self: Sized + Message { ... }
fn application_willContinueUserActivityWithType(
&self,
application: &NSApplication,
user_activity_type: &NSString,
) -> bool
where Self: Sized + Message { ... }
fn application_continueUserActivity_restorationHandler(
&self,
application: &NSApplication,
user_activity: &NSUserActivity,
restoration_handler: &DynBlock<dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>)>,
) -> bool
where Self: Sized + Message { ... }
fn application_didFailToContinueUserActivityWithType_error(
&self,
application: &NSApplication,
user_activity_type: &NSString,
error: &NSError,
)
where Self: Sized + Message { ... }
fn application_didUpdateUserActivity(
&self,
application: &NSApplication,
user_activity: &NSUserActivity,
)
where Self: Sized + Message { ... }
fn application_delegateHandlesKey(
&self,
sender: &NSApplication,
key: &NSString,
) -> bool
where Self: Sized + Message { ... }
fn applicationShouldAutomaticallyLocalizeKeyEquivalents(
&self,
application: &NSApplication,
) -> bool
where Self: Sized + Message { ... }
fn applicationWillFinishLaunching(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidFinishLaunching(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationWillHide(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidHide(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationWillUnhide(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidUnhide(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationWillBecomeActive(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidBecomeActive(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationWillResignActive(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidResignActive(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationWillUpdate(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidUpdate(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationWillTerminate(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationDidChangeScreenParameters(
&self,
notification: &NSNotification,
)
where Self: Sized + Message { ... }
fn applicationDidChangeOcclusionState(&self, notification: &NSNotification)
where Self: Sized + Message { ... }
fn applicationProtectedDataWillBecomeUnavailable(
&self,
notification: &NSNotification,
)
where Self: Sized + Message { ... }
fn applicationProtectedDataDidBecomeAvailable(
&self,
notification: &NSNotification,
)
where Self: Sized + Message { ... }
}
NSApplication
only.Expand description
Provided Methods§
Sourcefn applicationShouldTerminate(
&self,
sender: &NSApplication,
) -> NSApplicationTerminateReply
Available on crate feature NSResponder
only.
fn applicationShouldTerminate( &self, sender: &NSApplication, ) -> NSApplicationTerminateReply
NSResponder
only.Allowable return values are:
NSTerminateNow
- it is ok to proceed with termination
NSTerminateCancel
- the application should not be terminated
NSTerminateLater
- it may be ok to proceed with termination later. The application must call -replyToApplicationShouldTerminate:
with
YES
or
NO
once the answer is known
Note: This return value is for delegates who need to provide document modal alerts (sheets) in order to decide whether to quit.
Sourcefn application_openURLs(
&self,
application: &NSApplication,
urls: &NSArray<NSURL>,
)
Available on crate feature NSResponder
only.
fn application_openURLs( &self, application: &NSApplication, urls: &NSArray<NSURL>, )
NSResponder
only.This will be called for any URLs your application is asked to open. This includes URL types (CFBundleURLTypes) defined in your Info.plist, and Document types (
CFBundleDocumentTypes)
that have no associated
NSDocument
class. Document URLs that have an associated
NSDocument
class will be opened through
NSDocumentController.
If this is implemented, -application:openFiles:
and -application:openFile:
will not be called.
fn application_openFile( &self, sender: &NSApplication, filename: &NSString, ) -> bool
NSResponder
only.fn application_openFiles( &self, sender: &NSApplication, filenames: &NSArray<NSString>, )
NSResponder
only.fn application_openTempFile( &self, sender: &NSApplication, filename: &NSString, ) -> bool
NSResponder
only.fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool
NSResponder
only.fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool
NSResponder
only.Sourceunsafe fn application_openFileWithoutUI(
&self,
sender: &AnyObject,
filename: &NSString,
) -> bool
unsafe fn application_openFileWithoutUI( &self, sender: &AnyObject, filename: &NSString, ) -> bool
§Safety
sender
should be of the correct type.
fn application_printFile( &self, sender: &NSApplication, filename: &NSString, ) -> bool
NSResponder
only.Sourceunsafe fn application_printFiles_withSettings_showPrintPanels(
&self,
application: &NSApplication,
file_names: &NSArray<NSString>,
print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
show_print_panels: bool,
) -> NSApplicationPrintReply
Available on crate features NSPrintInfo
and NSResponder
only.
unsafe fn application_printFiles_withSettings_showPrintPanels( &self, application: &NSApplication, file_names: &NSArray<NSString>, print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>, show_print_panels: bool, ) -> NSApplicationPrintReply
NSPrintInfo
and NSResponder
only.§Safety
print_settings
generic should be of the correct type.
fn applicationShouldTerminateAfterLastWindowClosed( &self, sender: &NSApplication, ) -> bool
NSResponder
only.fn applicationShouldHandleReopen_hasVisibleWindows( &self, sender: &NSApplication, has_visible_windows: bool, ) -> bool
NSResponder
only.fn applicationDockMenu( &self, sender: &NSApplication, ) -> Option<Retained<NSMenu>>
NSMenu
and NSResponder
only.fn application_willPresentError( &self, application: &NSApplication, error: &NSError, ) -> Retained<NSError>
NSResponder
only.fn application_didRegisterForRemoteNotificationsWithDeviceToken( &self, application: &NSApplication, device_token: &NSData, )
NSResponder
only.fn application_didFailToRegisterForRemoteNotificationsWithError( &self, application: &NSApplication, error: &NSError, )
NSResponder
only.Sourceunsafe fn application_didReceiveRemoteNotification(
&self,
application: &NSApplication,
user_info: &NSDictionary<NSString, AnyObject>,
)
Available on crate feature NSResponder
only.
unsafe fn application_didReceiveRemoteNotification( &self, application: &NSApplication, user_info: &NSDictionary<NSString, AnyObject>, )
NSResponder
only.§Safety
user_info
generic should be of the correct type.
Sourcefn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool
Available on crate feature NSResponder
only.
fn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool
NSResponder
only.Method to opt-in to secure restorable state.
When this returns
YES:
NSCoders that are passed into the various
NSWindowRestoration
methods will
requiresSecureCoding
and have a
decodingFailurePolicy
of
NSDecodingFailurePolicySetErrorAndReturn.
Any
restorationClass
set on a window must explicitly conform to
NSWindowRestoration.
This method will be called prior to any state encoding or restoration.
Sourceunsafe fn application_willEncodeRestorableState(
&self,
app: &NSApplication,
coder: &NSCoder,
)
Available on crate feature NSResponder
only.
unsafe fn application_willEncodeRestorableState( &self, app: &NSApplication, coder: &NSCoder, )
NSResponder
only.Method called by -[NSApplication encodeRestorableStateWithCoder:]
to give the delegate a chance to encode any additional state into the
NSCoder.
If the restorable state managed by the delegate changes, you must call -[NSApplication invalidateRestorableState]
so that it will be re-encoded. See the header NSWindowRestoration.h
for more information.
§Safety
coder
possibly has further requirements.
Sourceunsafe fn application_didDecodeRestorableState(
&self,
app: &NSApplication,
coder: &NSCoder,
)
Available on crate feature NSResponder
only.
unsafe fn application_didDecodeRestorableState( &self, app: &NSApplication, coder: &NSCoder, )
NSResponder
only.Method called by -[NSApplication restoreStateWithCoder:]
to give the delegate a chance to restore its own state, which it may decode from the
NSCoder.
See the header NSWindowRestoration.h
for more information.
§Safety
coder
possibly has further requirements.
Sourcefn application_willContinueUserActivityWithType(
&self,
application: &NSApplication,
user_activity_type: &NSString,
) -> bool
Available on crate feature NSResponder
only.
fn application_willContinueUserActivityWithType( &self, application: &NSApplication, user_activity_type: &NSString, ) -> bool
NSResponder
only.This will be called on the main thread as soon as the user indicates they want to continue an activity in your application. The
NSUserActivity
object may not be available instantly, so use this as an opportunity to show the user that an activity will be continued shortly. Return
YES
to indicate that you are doing so. Return
NO
(or leave it unimplemented) and AppKit/UIKit will put up a default UI.
For each -application:willContinueUserActivityWithType:
invocation, you are guaranteed to get exactly one invocation of -application:continueUserActivity:restorationHandler:
on success, or -application:didFailToContinueUserActivityWithType:error:
if an error was encountered.
Sourcefn application_continueUserActivity_restorationHandler(
&self,
application: &NSApplication,
user_activity: &NSUserActivity,
restoration_handler: &DynBlock<dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>)>,
) -> bool
Available on crate features NSResponder
and NSUserActivity
and block2
only.
fn application_continueUserActivity_restorationHandler( &self, application: &NSApplication, user_activity: &NSUserActivity, restoration_handler: &DynBlock<dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>)>, ) -> bool
NSResponder
and NSUserActivity
and block2
only.This will be called on the main thread after the
NSUserActivity
object is available. Use the data you stored in the NSUserActivity object to re-create what the user was doing.
Returns: YES
to indicate that the activity was handled. Return
NO
(or leave it unimplemented) and AppKit will attempt to continue the user activity.
You should create/fetch any restorable objects associated with the user activity, and pass them to the restorationHandler. They will then get the above -restoreUserActivityState:
method invoked with the user activity. Invoking the
restorationHandler
is optional. It may be copied and invoked later, but must be invoked on the main thread.
If this user activity was created automatically by having
NSUbiquitousDocumentUserActivityType
in a
CFBundleDocumentTypes
entry, AppKit can automatically restore the NSUserActivity on OS X if NO is returned, or this method is unimplemented. It will do so by creating a document of the appropriate type using the URL stored in the userInfo under the
NSUserActivityDocumentURLKey.
The document will have -restoreUserActivity:
called on it.
Sourcefn application_didFailToContinueUserActivityWithType_error(
&self,
application: &NSApplication,
user_activity_type: &NSString,
error: &NSError,
)
Available on crate feature NSResponder
only.
fn application_didFailToContinueUserActivityWithType_error( &self, application: &NSApplication, user_activity_type: &NSString, error: &NSError, )
NSResponder
only.There are instances where continuing a
NSUserActivity
may fail. This will get called on the main thread if it does so. If it is unimplemented, AppKit will present the error.
Sourcefn application_didUpdateUserActivity(
&self,
application: &NSApplication,
user_activity: &NSUserActivity,
)
Available on crate feature NSResponder
only.
fn application_didUpdateUserActivity( &self, application: &NSApplication, user_activity: &NSUserActivity, )
NSResponder
only.This will be called on the main thread when a user activity managed by AppKit/UIKit has been updated. You should use this as a last chance to add additional data to the
userActivity.
Sourcefn application_delegateHandlesKey(
&self,
sender: &NSApplication,
key: &NSString,
) -> bool
Available on crate feature NSResponder
only.
fn application_delegateHandlesKey( &self, sender: &NSApplication, key: &NSString, ) -> bool
NSResponder
only.Returns: YES
if the receiving delegate object can respond to key value coding messages for a specific keyed attribute, to-one relationship, or to-many relationship. Return
NO
otherwise.
Sourcefn applicationShouldAutomaticallyLocalizeKeyEquivalents(
&self,
application: &NSApplication,
) -> bool
Available on crate feature NSResponder
only.
fn applicationShouldAutomaticallyLocalizeKeyEquivalents( &self, application: &NSApplication, ) -> bool
NSResponder
only.This method will be called once during application launch at -[NSApplication finishLaunching]
.
Returns: NO
if the receiving delegate object wishes to opt-out of system-wide keyboard shortcut localization for all application-supplied menus. Return
YES
by default for apps linked against 12.0 and later SDK.