iOS Guides | Samples

MonoTouch.UIKit.UIKeyCommand Class

Maps hardware key presses to custom actions.

See Also: UIKeyCommand

Syntax

[MonoTouch.Foundation.Register("UIKeyCommand", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 7, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class UIKeyCommand : NSObject, INSCopying, INSSecureCoding, IDisposable

Remarks

UIKeyCommand objects are only generated with an attached hardware keyboard.

To create keyboard accelerators, developers must create a Selector that is associated with a method of type Action<UIKeyCommand> with an appropriate ExportAttribute:

C# Example

[Export("NewFileAccelerator:")]
void NewFileAccelerator(UIKeyCommand cmd)
{
   //etc...
}

public override void ViewDidLoad ()
{
    base.ViewDidLoad ();

    var actionSelector = new Selector("NewFileAccelerator:");
    accelerator = UIKeyCommand.Create((NSString) "N", UIKeyModifierFlags.Command, actionSelector);

    AddKeyCommand(accelerator);
}

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIKeyCommand are listed below.

See Also: NSObject

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
override
ClassHandleIntPtr. The handle for this class.
DiscoverabilityTitleNSString. The label to be used for the keyboard shortcut.
[read-only]
static
DownArrowNSString. Represents the value associated with the constant UIKeyInputDownArrow
[read-only]
static
EscapeNSString. Represents the value associated with the constant UIKeyInputEscape
[read-only]
InputNSString. The string of characters that must be pressed to match this key command. Read-only.
[read-only]
static
LeftArrowNSString. Represents the value associated with the constant UIKeyInputLeftArrow
[read-only]
ModifierFlagsUIKeyModifierFlags. A bitmask of modifier flags that must be pressed to match this key command. Read-only.
[read-only]
static
RightArrowNSString. Represents the value associated with the constant UIKeyInputRightArrow
[read-only]
static
UpArrowNSString. Represents the value associated with the constant UIKeyInputUpArrow

Public Methods

Copy(NSZone) : NSObject
Performs a copy of the underlying Objective-C object.
static
Create(NSString, UIKeyModifierFlags, Selector) : UIKeyCommand
Factory method that creates a UIKeyCommand.
static
Create(NSString, UIKeyModifierFlags, Selector, NSString) : UIKeyCommand
Factory method that instantiates a new UIKeyCommand.