Instance Method

application:delegateHandlesKey:

Sent by Cocoa’s built-in scripting support during execution of get or set script commands to find out if the delegate can handle operations on the specified key-value key.

Declaration

- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key;

Parameters

sender

The app object associated with the delegate.

key

The key to be handled.

Return Value

YES if your delegate handles the key or NO if it does not.

Discussion

The method should return YES if the delegate for the app sender handles the key specified by key, which means it can get or set the scriptable property or element that corresponds to that key. The app implements methods for each of the keys that it handles, where the method name matches the key.

For example, a scriptable app that doesn’t use Cocoa’s document-based app architecture can implement this method to supply its own document ordering. Such an app might want to do this because the standard app delegate expects to work with a document-based app. The TextEdit app (whose source is distributed with macOS developer tools) provides the following implementation:

return [key isEqualToString:@"orderedDocuments"];

TextEdit then implements the orderedDocuments method in its controller class to return an ordered list of documents. An app with its own window ordering might add a test for the key orderedWindows so that its delegate can provide its own version of orderedWindows.

See Also

Scripting Your App

orderedDocuments

An array of document objects arranged according to the front-to-back ordering of their associated windows.

orderedWindows

An array of window objects arranged according to their front-to-back ordering on the screen.