Contents

performKeyEquivalent(with:)

Implemented by subclasses to respond to key equivalents (also known as keyboard shortcuts).

Declaration

func performKeyEquivalent(with event: NSEvent) -> Bool

Parameters

  • event:

    The key-down event object representing a key equivalent.

Return Value

true if theEvent is a key equivalent that the view handled, false if it is not a key equivalent that it should handle.

Discussion

If the view’s key equivalent is the same as the characters of the key-down event theEvent, as returned by charactersIgnoringModifiers, the view should take the appropriate action and return true. Otherwise, it should return the result of invoking super‘s implementation. The default implementation of this method simply passes the message down the view hierarchy (from superviews to subviews) and returns false if none of the view’s subviews responds true.

See Also

Handling Events in the View