Type Method

commandWithTitle:image:action:input:modifierFlags:propertyList:alternates:

Creates a key command with alternatives that you can use as a menu element with a shortcut key, or a shortcut key only for a view controller.

Declaration

+ (instancetype)commandWithTitle:(NSString *)title image:(UIImage *)image action:(SEL)action input:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags propertyList:(id)propertyList alternates:(NSArray<UICommandAlternate *> *)alternates;

Parameters

title

The title to display for the key command.

image

The image to display next to the key command's title. Only the contextSystem menu system supports the display of an image, and only when the app runs in iOS.

action

The action to take after the user selects the key command.

input

The keys that the user must press. The string must contain one or more characters corresponding to the keys the user pressed. For a list of special characters that do not have a textual representation, see Input Strings for Special Keys.

modifierFlags

The bit mask of modifier keys that the user must press. You can use this parameter to specify which modifier keys (Command, Option, and so on) the user must also press. You may specify more than one modifier key. For a list of possible values, see UIKeyModifierFlags.

propertyList

An object that contains data to associate with the key command.

alternates

An array of alternatives for the key command.

Return Value

A newly initialized key command object.

Discussion

After creating a key command object, you can:

See Also

Creating a Key Command Object

+ commandWithTitle:image:action:input:modifierFlags:propertyList:

Creates a key command that you can use as a menu element with a shortcut key, or a shortcut key only for a view controller.

+ keyCommandWithInput:modifierFlags:action:

Creates a new key command object that matches the specified input.

+ keyCommandWithInput:modifierFlags:action:discoverabilityTitle:

Creates and returns a new key command object that matches the specified input and has a title.

Deprecated
Adding Menus and Shortcuts to the Menu Bar and User Interface

Provide quick access to useful actions by adding menus and keyboard shortcuts to your Mac Catalyst app.