Mac Developer Library

Developer

AppKit Framework Reference NSEvent Class Reference

Options
Deployment Target:

On This Page
Language:

NSEvent

Inheritance


  • NSObject
  • NSEvent

Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

An NSEvent object, or simply an event, contains information about an input action such as a mouse click or a key press. AppKit associates each such user action with a window, reporting the event to the application that created the window. The NSEvent object contains pertinent information about each event, such as where the cursor was located or which character was typed. As the application receives events, it temporarily places them in a buffer called the event queue. When the application is ready to process an event, it takes one from the queue.

NSEvent objects can also represent tablet-pointing and tablet-proximity events. A tablet-proximity event is generated when a pointing device enters or leaves the proximity of its tablet; such event objects have a type of NSTypeProximity or a mouse subtype of NSTabletProximityEventSubtype. A tablet-pointing event is generated when a pointing device changes state, such as location, pressure, or tilt; such event objects have a type of NSTypePoint or a mouse subtype of NSTabletPointEventSubtype. AppKit reports all pure tablet events to responder objects through the NSResponder methods tabletPoint: and tabletProximity:. Mouse events can also contain tablet data (as event subtypes), so you can handle these events by overriding the NSResponder methods mouseDown:, mouseDragged:, and mouseUp:.

Events can also represent touch and gesture events. Magnify (pinch), swipe, and rotate masks are supported, as are more generic gesture masks. Using the touchesMatchingPhase:inView: method, a view can get all of the touch events associated with a gesture without overriding the individual touch responder methods defined in NSResponder.

Pressure events are supported on devices that support pressure sensitivity. These events are reported as event type NSEventTypePressure, and invoke the responder method pressureChangeWithEvent: in NSResponder or pressureChangeWithEvent: in NSGestureRecognizer.

You can create application event monitors that call handlers in block objects for certain event types that are sent through the NSApplication sendEvent: method. You can create a local monitor that will be informed of the events in your application and allow you to modify or cancel them. You can also create a global event monitor that allows you to monitor events in other applications, although you are unable to alter those events. See Monitoring Application Events for more information.

  • Returns a new NSEvent object describing a key event.

    Declaration

    Swift

    class func keyEventWithType(_ type: NSEventType, location location: NSPoint, modifierFlags flags: NSEventModifierFlags, timestamp time: NSTimeInterval, windowNumber windowNum: Int, context context: NSGraphicsContext?, characters characters: String, charactersIgnoringModifiers unmodCharacters: String, isARepeat repeatKey: Bool, keyCode code: UInt16) -> NSEvent?

    Objective-C

    + (NSEvent *)keyEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(NSEventModifierFlags)flags timestamp:(NSTimeInterval)time windowNumber:(NSInteger)windowNum context:(NSGraphicsContext *)context characters:(NSString *)characters charactersIgnoringModifiers:(NSString *)unmodCharacters isARepeat:(BOOL)repeatKey keyCode:(unsigned short)code

    Parameters

    type

    One of the following event-type constants: NSKeyDown, NSKeyUp, NSFlagsChanged. If anything else is specified, an NSInternalInconsistencyException is raised.

    location

    The cursor location in the base coordinate system of the window specified by windowNum.

    flags

    An integer bit field containing any of the modifier key masks described in Constants, combined using the C bitwise OR operator.

    time

    The time the event occurred in seconds since system startup.

    windowNum

    An integer that identifies the window device associated with the event, which is associated with the NSWindow that will receive the event.

    context

    The display graphics context of the event.

    characters

    A string of characters associated with the key event. Though most key events contain only one character, it is possible for a single keypress to generate a series of characters.

    unmodCharacters

    The string of characters generated by the key event as if no modifier key had been pressed (except for Shift). This argument is useful for getting the “basic” key value in a hardware-independent manner.

    repeatKey

    YEStrue if the key event is a repeat caused by the user holding the key down, NOfalse if the key event is new.

    code

    A number that identifies the keyboard key associated with the key event. Its value is hardware-independent.

    Return Value

    The created NSEvent instance or nil if the instance could not be created.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a new NSEvent object describing a mouse-down, -up, -moved, or -dragged event.

    Declaration

    Swift

    class func mouseEventWithType(_ type: NSEventType, location location: NSPoint, modifierFlags flags: NSEventModifierFlags, timestamp time: NSTimeInterval, windowNumber windowNum: Int, context context: NSGraphicsContext?, eventNumber eventNumber: Int, clickCount clickNumber: Int, pressure pressure: Float) -> NSEvent?

    Objective-C

    + (NSEvent *)mouseEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(NSEventModifierFlags)flags timestamp:(NSTimeInterval)time windowNumber:(NSInteger)windowNum context:(NSGraphicsContext *)context eventNumber:(NSInteger)eventNumber clickCount:(NSInteger)clickNumber pressure:(float)pressure

    Parameters

    type

    One of the modifier key masks described in NSEventType, or an NSInternalInconsistencyException is raised.

    location

    The cursor location in the base coordinate system of the window specified by windowNum.

    flags

    An integer bit field containing any of the modifier key masks described in Constants, combined using the C bitwise OR operator.

    time

    The time the event occurred in seconds since system startup.

    windowNum

    An integer that identifies the window device associated with the event, which is associated with the NSWindow that will receive the event.

    context

    The display graphics context of the event.

    eventNumber

    An identifier for the new event. It’s normally taken from a counter for mouse events, which continually increases as the application runs.

    clickNumber

    The number of mouse clicks associated with the mouse event.

    pressure

    A value from 0.0 to 1.0 indicating the pressure applied to the input device on a mouse event, used for an appropriate device such as a graphics tablet. For devices that aren’t pressure-sensitive, the value should be either 0.0 or 1.0.

    Return Value

    The created NSEvent instance or nil if the instance could not be created.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a new NSEvent object describing a tracking-rectangle or cursor-update event.

    Declaration

    Swift

    class func enterExitEventWithType(_ type: NSEventType, location location: NSPoint, modifierFlags flags: NSEventModifierFlags, timestamp time: NSTimeInterval, windowNumber windowNum: Int, context context: NSGraphicsContext?, eventNumber eventNumber: Int, trackingNumber trackingNumber: Int, userData userData: UnsafeMutablePointer<Void>) -> NSEvent?

    Objective-C

    + (NSEvent *)enterExitEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(NSEventModifierFlags)flags timestamp:(NSTimeInterval)time windowNumber:(NSInteger)windowNum context:(NSGraphicsContext *)context eventNumber:(NSInteger)eventNumber trackingNumber:(NSInteger)trackingNumber userData:(void *)userData

    Parameters

    type

    One of the following event-type constants: NSMouseEntered, NSMouseExited, NSCursorUpdate. If the specified constant is not one of these, an NSInternalInconsistencyException is raised

    location

    The cursor location in the base coordinate system of the window specified by windowNum.

    flags

    An integer bit field containing any of the modifier key masks described in Constants, combined using the C bitwise OR operator.

    time

    The time the event occurred in seconds since system startup.

    windowNum

    An integer that identifies the window device associated with the event, which is associated with the NSWindow that will receive the event.

    context

    The display graphics context of the event.

    eventNumber

    An identifier for the new event. It’s normally taken from a counter for mouse events, which continually increases as the application runs.

    trackingNumber

    A number that identifies the tracking rectangle. This identifier is the same as that returned by the NSView method addTrackingRect:owner:userData:assumeInside:.

    userData

    Data arbitrarily associated with the tracking rectangle when it was set up using the NSView method addTrackingRect:owner:userData:assumeInside:.

    Return Value

    The created NSEvent object or nil if the object could not be created.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a new NSEvent object describing a custom event.

    Declaration

    Swift

    class func otherEventWithType(_ type: NSEventType, location location: NSPoint, modifierFlags flags: NSEventModifierFlags, timestamp time: NSTimeInterval, windowNumber windowNum: Int, context context: NSGraphicsContext?, subtype subtype: Int16, data1 data1: Int, data2 data2: Int) -> NSEvent?

    Objective-C

    + (NSEvent *)otherEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(NSEventModifierFlags)flags timestamp:(NSTimeInterval)time windowNumber:(NSInteger)windowNum context:(NSGraphicsContext *)context subtype:(short)subtype data1:(NSInteger)data1 data2:(NSInteger)data2

    Parameters

    type

    One of the following event-type constants:

    • NSAppKitDefined

    • NSSystemDefined

    • NSApplicationDefined

    • NSPeriodic

    If type is anything else, an NSInternalInconsistencyException is raised. Your code should only create events of type NSApplicationDefined.

    location

    The cursor location in the base coordinate system of the window specified by windowNum.

    flags

    An integer bit field containing any of the modifier key masks described in Constants, combined using the C bitwise OR operator.

    time

    The time the event occurred in seconds since system startup.

    windowNum

    An integer that identifies the window device associated with the event, which is associated with the NSWindow that will receive the event.

    context

    The display graphics context of the event.

    subtype

    A numeric identifier that further differentiates custom events of types NSAppKitDefined, NSSystemDefined, and NSApplicationDefined. NSPeriodic events don’t use this attribute.

    data1

    Additional data associated with the event. NSPeriodic events don’t use these attributes.

    data2

    Additional data associated with the event. NSPeriodic events don’t use these attributes.

    Return Value

    The created NSEvent object or nil if the object couldn't be created.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates an event object that is based on a Carbon type of event.

    Declaration

    Swift

    init?(eventRef eventRef: UnsafePointer<Void>) -> NSEvent

    Objective-C

    + (NSEvent *)eventWithEventRef:(const void *)eventRef

    Parameters

    eventRef

    The EventRef opaque type to be associated with the created NSEvent object.

    Return Value

    An autoreleased NSEvent object corresponding to eventRef or nil if eventRef cannot be converted into an equivalent NSEvent object.

    Discussion

    This method is valid for all events. The created NSEvent object retains the EventRef object and is released when the NSEvent object is freed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    See Also

    eventRef

  • Creates and returns an event object that is based on a Core Graphics type of event.

    Declaration

    Swift

    init?(CGEvent cgEvent: CGEvent) -> NSEvent

    Objective-C

    + (NSEvent *)eventWithCGEvent:(CGEventRef)cgEvent

    Parameters

    cgEvent

    A CGEventRef opaque type that represents an event.

    Return Value

    An autoreleased NSEvent object that is equivalent to cgEvent.

    Discussion

    The returned object retains the CGEventRef object (cgEvent) until it (the Objective-C object) is freed—it then releases the CGEventRef object. If no Cocoa event corresponds to the CGEventRef object, this method returns nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    See Also

    CGEvent

  • context context Property

    The display graphics context for this event. (read-only)

    Declaration

    Swift

    var context: NSGraphicsContext? { get }

    Objective-C

    @property(readonly, strong) NSGraphicsContext *context

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The receiver’s location in the base coordinate system of the associated window. (read-only)

    Declaration

    Swift

    var locationInWindow: NSPoint { get }

    Objective-C

    @property(readonly) NSPoint locationInWindow

    Discussion

    For non-mouse events the return value of this method is undefined.

    With NSMouseMoved and possibly other events, the event can have a nil window (that is, the window property contains nil). In this case, locationInWindow returns the event location in screen coordinates.

    In a method of a custom view that handles mouse events, you commonly use the locationInWindow property in conjunction with the NSView method convertPoint:fromView:to get the mouse location in the view’s coordinate system. For example:

    • NSPoint event_location = theEvent.locationInWindow;
    • NSPoint local_point = [self convertPoint:event_location fromView:nil];

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    window

  • An integer bit field indicating the event’s modifier keys. (read-only)

    Declaration

    Swift

    var modifierFlags: NSEventModifierFlags { get }

    Objective-C

    @property(readonly) NSEventModifierFlags modifierFlags

    Discussion

    You can examine individual flag settings using the C bitwise AND operator with the predefined key masks described in Constants. The lower 16 bits of the modifier flags are reserved for device-dependent bits.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • timestamp timestamp Property

    The time when the event occurred in seconds since system startup. (read-only)

    Declaration

    Swift

    var timestamp: NSTimeInterval { get }

    Objective-C

    @property(readonly) NSTimeInterval timestamp

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • type type Property

    The event’s type. (read-only)

    Declaration

    Swift

    var type: NSEventType { get }

    Objective-C

    @property(readonly) NSEventType type

    Discussion

    The possible values are described in NSEventType.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • window window Property

    The window object associated with the event. (read-only)

    Declaration

    Swift

    unowned(unsafe) var window: NSWindow? { get }

    Objective-C

    @property(readonly, assign) NSWindow *window

    Discussion

    Periodic events do not have a window. The result of accessing this property on a periodic event is undefined.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    windowNumber

  • The identifier for the window device associated with the event. (read-only)

    Declaration

    Swift

    var windowNumber: Int { get }

    Objective-C

    @property(readonly) NSInteger windowNumber

    Discussion

    Periodic events do not have a window. The result of accessing this property on a periodic event is undefined.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    window

  • eventRef eventRef Property

    An opaque Carbon type associated with this event. (read-only)

    Declaration

    Swift

    var eventRef: UnsafePointer<Void> { get }

    Objective-C

    @property(readonly) const void *eventRef

    Discussion

    This method is valid for all types of events. The EventRef object is retained by the receiver, so it is valid as long as the NSEvent object is valid, and is released when the NSEvent object is freed. You can use RetainEvent to extend the lifetime of the EventRef object, with a corresponding ReleaseEvent when you are done with it.

    The system typically creates user-input events with an associated EventRef. Other NSEvent objects create an EventRef when this property is first accessed, if possible. If there is no equivalent NSEvent for this event, the property is set to NULL.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • CGEvent CGEvent Property

    The Core Graphics event object corresponding to this event. (read-only)

    Declaration

    Swift

    var CGEvent: CGEvent? { get }

    Objective-C

    @property(readonly) CGEventRef CGEvent

    Discussion

    The returned CGEventRef opaque type is autoreleased. If no CGEventRef object corresponding to the NSEvent object can be created, this method returns NULL.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the currently pressed modifier flags.

    Declaration

    Swift

    class func modifierFlags() -> NSEventModifierFlags

    Objective-C

    + (NSEventModifierFlags)modifierFlags

    Return Value

    A mask of the current modifiers using the values in Modifier Flags.

    Discussion

    This returns the state of devices combined with synthesized events at the moment, independent of which events have been delivered via the event stream.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the length of time a key must be held down in order to generate the first key repeat event.

    Declaration

    Swift

    class func keyRepeatDelay() -> NSTimeInterval

    Objective-C

    + (NSTimeInterval)keyRepeatDelay

    Return Value

    The delay interval, in seconds.

    Discussion

    This is a system setting, overriding this method will have no effect.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the length between subsequent key repeat events being posted.

    Declaration

    Swift

    class func keyRepeatInterval() -> NSTimeInterval

    Objective-C

    + (NSTimeInterval)keyRepeatInterval

    Return Value

    The repeat interval, in seconds.

    Discussion

    This is a system setting, overriding this method will have no effect.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • The characters associated with a key-up or key-down event. (read-only)

    Declaration

    Swift

    var characters: String? { get }

    Objective-C

    @property(readonly, copy) NSString *characters

    Discussion

    These characters are derived from a keyboard mapping that associates various key combinations with Unicode characters. This property is only valid for key-up and key-down events. It raises an NSInternalInconsistencyException if accessed on any other kind of event object.

    This property is set to an empty string for dead keys, such as Option-e. However, for a key combination such as Option-Shift-e this property is set to the standard accent ("´").

    For a list of constants corresponding to commonly-used Unicode characters, see NSText Class Reference.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The characters generated by a key event as if no modifier key (except for Shift) applies. (read-only)

    Declaration

    Swift

    var charactersIgnoringModifiers: String? { get }

    Objective-C

    @property(readonly, copy) NSString *charactersIgnoringModifiers

    Discussion

    Raises an NSInternalInconsistencyException if accessed on a non-key event.

    This property is set to the non-modifier key character pressed for dead keys, such as Option-e. For example, Option-e (no shift key) returns an “e" for this method, whereas the characters property returns an empty string.

    This property is useful for determining “basic” key values in a hardware-independent manner, enabling such features as keyboard equivalents defined in terms of modifier keys plus character keys. For example, to determine if the user typed Alt-S, you don’t have to know whether Alt-S generates a German double ess, an integral sign, or a section symbol. You simply examine the string contained by this property along with the event’s modifier flags, checking for “s” and NSAlternateKeyMask.

    For a list of constants corresponding to commonly-used Unicode characters, see NSText Class Reference.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • ARepeat ARepeat Property

    A Boolean value that indicates whether the key event is a repeat. (read-only)

    Declaration

    Swift

    var ARepeat: Bool { get }

    Objective-C

    @property(getter=isARepeat, readonly) BOOL ARepeat

    Discussion

    Contains YEStrue if the key event is a repeat caused by the user holding the key down; otherwise, NOfalse. Raises an NSInternalInconsistencyException if sent to an NSFlagsChanged event or other non-key event.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • keyCode keyCode Property

    The virtual key code for the keyboard key associated with a key event. (read-only)

    Declaration

    Swift

    var keyCode: UInt16 { get }

    Objective-C

    @property(readonly) unsigned short keyCode

    Discussion

    Raises an NSInternalInconsistencyException if sent to a non-key event.

    The property’s value is hardware-independent. The value returned is the same as the value returned in the kEventParamKeyCode when using Carbon Events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the indices of the currently depressed mouse buttons.

    Declaration

    Swift

    class func pressedMouseButtons() -> Int

    Objective-C

    + (NSUInteger)pressedMouseButtons

    Return Value

    The indices of the currently depressed mouse buttons.

    Discussion

    A return value of 1 << 0 corresponds to the left mouse button, 1 << 1 corresponds to the right mouse button, 1<< n, n >=2 correspond to other mouse buttons.

    This returns the state of devices combined with synthesized events at the moment, independent of which events have been delivered via the event stream, so this method is not suitable for tracking.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the time, in seconds, in which a second mouse click must occur in order to be considered a double click.

    Declaration

    Swift

    class func doubleClickInterval() -> NSTimeInterval

    Objective-C

    + (NSTimeInterval)doubleClickInterval

    Return Value

    The double-click time interval, in seconds.

    Discussion

    This is a system setting, overriding this method will have no effect.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Reports the current mouse position in screen coordinates.

    Declaration

    Swift

    class func mouseLocation() -> NSPoint

    Objective-C

    + (NSPoint)mouseLocation

    Return Value

    The current mouse location in screen coordinates.

    Discussion

    This method is similar to the NSWindow method mouseLocationOutsideOfEventStream. It returns the location regardless of the current event or pending events. The difference between these methods is that mouseLocationOutsideOfEventStream returns a point in the receiving window’s coordinates and mouseLocation returns the same information in screen coordinates.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The button number for a mouse event. (read-only)

    Declaration

    Swift

    var buttonNumber: Int { get }

    Objective-C

    @property(readonly) NSInteger buttonNumber

    Discussion

    This property is intended for use with the NSOtherMouseDown, NSOtherMouseUp, and NSOtherMouseDragged events, but will return values for NSLeftMouse... and NSRightMouse... events also. If this event is not a mouse event, the property is set to 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.1 and later.

  • The number of mouse clicks associated with a mouse-down or mouse-up event. (read-only)

    Declaration

    Swift

    var clickCount: Int { get }

    Objective-C

    @property(readonly) NSInteger clickCount

    Discussion

    Raises an NSInternalInconsistencyException if accessed on a non-mouse event.

    This property is set to 0 for a mouse-up event if a time threshold has passed since the corresponding mouse-down event. This is because if this time threshold passes before the mouse button is released, it is no longer considered a mouse click, but a mouse-down event followed by a mouse-up event.

    The return value of this method is meaningless for events other than mouse-down or mouse-up events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Controls whether mouse-movement event coalescing is enabled.

    Declaration

    Swift

    class func setMouseCoalescingEnabled(_ flag: Bool)

    Objective-C

    + (void)setMouseCoalescingEnabled:(BOOL)flag

    Parameters

    flag

    YEStrue to enable mouse-movement event coalescing, NOfalse to disable it.

    Discussion

    This method affects mouse-moved, mouse-dragged, and tablet events. Mouse-movement event coalescing is enabled by default.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Indicates whether mouse-movement event coalescing is enabled.

    Declaration

    Swift

    class func isMouseCoalescingEnabled() -> Bool

    Objective-C

    + (BOOL)isMouseCoalescingEnabled

    Return Value

    YEStrue if mouse-movement event coalescing is enabled, NOfalse if it is disabled.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The associated events mask of a mouse event. (read-only)

    Declaration

    Swift

    var associatedEventsMask: NSEventMask { get }

    Objective-C

    @property(readonly) NSEventMask associatedEventsMask

    Discussion

    This property pertains to mouse events. It is used to determine whether the input device issuing the event can simultaneously issue events of type NSEventTypePressure. This can be useful if you need to determine whether to initiate or begin initiating a pressure-related action when a mouse event occurs.

    For example, suppose you are writing a painting app that uses pressure to determine the size of brush stroke to apply. You can use associatedEventsMask to determine whether a mouse-click event is occurring simultaneously with a pressure event. If not, the user may not have pressure-sensitive hardware and you can apply a default size to the brush stroke.

    Listing 1Example usage

    Objective-C

    • if (event.associatedEventMask & NSEventMaskPressure) {
    • self.pressure = 0; // Prepare for pressure events
    • } else if (event.subtype == NSTabletPointEventSubtype) {
    • self.pressure = event.pressure; // For tablets, the pressure value is embedded in the mouse event
    • } else {
    • self.pressure = 1; // The input device does not support pressure sensitivity, so default to full pressure
    • }

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10.3 and later.

  • data1 data1 Property

    Additional data associated with this event. (read-only)

    Declaration

    Swift

    var data1: Int { get }

    Objective-C

    @property(readonly) NSInteger data1

    Discussion

    The value contained by this property is dependent on the event type, and is defined by the originator of the event. Raises an NSInternalInconsistencyException if accessed on an object that is not a NSAppKitDefined, NSSystemDefined, NSApplicationDefined, or NSPeriodic event.

    NSPeriodic events don’t use this attribute.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • data2 data2 Property

    Additional data associated with this event. (read-only)

    Declaration

    Swift

    var data2: Int { get }

    Objective-C

    @property(readonly) NSInteger data2

    Discussion

    The value contained by this property is dependent on the event type, and is defined by the originator of the event. Raises an NSInternalInconsistencyException if accessed on an object that is not a NSAppKitDefined, NSSystemDefined, NSApplicationDefined, or NSPeriodic event.

    NSPeriodic events don’t use this attribute.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • subtype subtype Property

    The event’s subtype. (read-only)

    Declaration

    Swift

    var subtype: NSEventSubtype { get }

    Objective-C

    @property(readonly) NSEventSubtype subtype

    Discussion

    Raises an NSInternalInconsistencyException if accessed on an event that is not of type NSAppKitDefined, NSSystemDefined, NSApplicationDefined, or NSPeriodic. This property is also valid for mouse events. See Constants for the predefined mouse and tablet subtypes.

    NSPeriodic events don’t use this property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • deltaX deltaX Property

    The x-coordinate change for mouse-move, mouse-drag, and swipe events. (read-only)

    Declaration

    Swift

    var deltaX: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat deltaX

    Discussion

    This property is only valid for scroll wheel, mouse-move, mouse-drag, and swipe events. For swipe events, a nonzero value represents a horizontal swipe: -1 for swipe right and 1 for swipe left.

    For scroll wheel events, use scrollingDeltaX instead.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • deltaY deltaY Property

    The y-coordinate change for mouse-move, mouse-drag, and swipe events. (read-only)

    Declaration

    Swift

    var deltaY: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat deltaY

    Discussion

    This property is only valid for scroll wheel, mouse-move, mouse-drag, and swipe events. For swipe events, a nonzero value represents a vertical swipe: -1 for swipe down and 1 for swipe up.

    For scroll wheel events, use scrollingDeltaY instead.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • deltaZ deltaZ Property

    The z-coordinate change for a scroll wheel, mouse-move, or mouse-drag event. (read-only)

    Declaration

    Swift

    var deltaZ: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat deltaZ

    Discussion

    This value is typically 0.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    deltaX
    deltaY

  • pressure pressure Property

    A value from 0.0 through 1.0 indicating the degree of pressure applied to an appropriate input device. (read-only)

    Declaration

    Swift

    var pressure: Float { get }

    Objective-C

    @property(readonly) float pressure

    Discussion

    For input devices that are pressure-sensitive, the value is increased as pressure is applied to the device.

    For NSEventTypePressure events, pressure value relates to the current stage of the gesture event. Each stage has its own pressure curve. For example, pressure ranges from 0.0 through 1.0 for a stage 1 event, and 0.0 through 1.0 for a stage 2 event. Pressure readings should be retrieved for a single stage of a gesture only, and should not be combined to achieve a wider range of pressure levels. In most cases, retrieving pressure during stage 1 is sufficient and appropriate for supporting variable input. Stage 1 pressure is the most physically comfortable for the user. Stage 2 pressure should only be used in rare circumstances where additional tactile feedback is necessary prior to retrieving pressure level.

    For input devices that aren’t pressure-sensitive, the value is either 0.0 or 1.0. An NSInternalInconsistencyException exception is raised if this property is accessed on an event other than a mouse-up, mouse-down, mouse-drag, NSTabletPoint, or NSEventTypePressure event.

    For tablet pointing devices that are in proximity, the pressure value is 0.0 if the user is not actually touching the tablet.

    Pressure is not intended to measure weight.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • stage stage Property

    A value of 0, 1, or 2, indicating the stage of a gesture event of type NSEventTypePressure. (read-only)

    Declaration

    Swift

    var stage: Int { get }

    Objective-C

    @property(readonly) NSInteger stage

    Discussion

    Gesture events of type NSEventTypePressure can go through multiple stages. This property indicates the current stage of the event.

    If this property has a value of 0, there is not enough pressure being applied to initiate or continue with the gesture. Effectively, this value will exist only when an event ends, as some level of pressure will be applied throughout the gesture.

    A value of 1 indicates that the user has applied enough pressure to represent a mouse-down event.

    A value of 2 suggests that the user has applied additional pressure beyond what is required for a typical mouse-down event. A stage value of 2 should generally be used to initiate a lookup or immediate action, for example, force clicking (pressing harder) on an element, such as a contact in an email message, to display a Quick Look window or to enter edit mode.

    Typically, as a gesture event moves between stages, the user will receive light tactile feedback.

    Stages do not always occur in sequence. For example, ending the gesture with a stage value of 2 may result in an immediate transition to a stage value of 0. As such, the gesture event may skip over stage 1.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10.3 and later.

  • The transition value for the stage of a pressure gesture event of type NSEventTypePressure. (read-only)

    Declaration

    Swift

    var stageTransition: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat stageTransition

    Discussion

    This property is specifically intended to provide a value for the transition animation between the stages of a pressure gesture event.

    Gesture events of type NSEventTypePressure go through stages, and transitions occur between these stages. This property indicates a transition value between the current stage and the next or prior stage.

    This value is distinct from pressure. It immediately resets to 0 as soon as a stage transition occurs. However, this value does not then immediately begin to fluctuate. The value only starts to change as a new stage begins to approach. It then continues to rise or fall throughout the transition, until that new stage is reached.

    As pressure increases for the gesture and a new stage approaches, this property provides a value between 0 and 1, indicating the approach of the next stage. When pressure is reduced for the gesture and a new stage is approached, this property provides a value between 0 and -1, indicating the approach of the current stage’s release.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10.3 and later.

  • A mask whose set bits indicate the capabilities of the tablet device that generated this event. (read-only)

    Declaration

    Swift

    var capabilityMask: Int { get }

    Objective-C

    @property(readonly) NSUInteger capabilityMask

    Discussion

    These bits are vendor-defined. This property is valid only for mouse events with a subtype of NSTabletProximityEventSubtype and for events of type NSTabletProximity; otherwise, it is set to 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • deviceID deviceID Property

    A special identifier that is used to match tablet-pointer and tablet-proximity events. (read-only)

    Declaration

    Swift

    var deviceID: Int { get }

    Objective-C

    @property(readonly) NSUInteger deviceID

    Discussion

    All tablet-pointer events generated in the period between the device entering and leaving tablet proximity have the same device ID. This property is valid only for mouse events with subtype NSTabletPointEventSubtype or NSTabletProximityEventSubtype, and for NSTabletPoint and NSTabletProximity events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • A Boolean value that indicates whether a pointing device is entering or leaving the proximity of its tablet. (read-only)

    Declaration

    Swift

    var enteringProximity: Bool { get }

    Objective-C

    @property(getter=isEnteringProximity, readonly) BOOL enteringProximity

    Discussion

    This property is set to YEStrue when the pointing device enters the proximity of its tablet and NOfalse when it leaves.

    This method is valid only for mouse events with subtype NSTabletProximityEventSubtype and for NSTabletProximity events; otherwise it is set to NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • The index of the pointing device currently in proximity with the tablet. (read-only)

    Declaration

    Swift

    var pointingDeviceID: Int { get }

    Objective-C

    @property(readonly) NSUInteger pointingDeviceID

    Discussion

    This index is significant for multimode (or Dual Tracking) tablets that support multiple concurrent pointing devices; the index is incremented for each pointing device that comes into proximity. Otherwise, zero is always returned. This property is valid for mouse events with subtype NSTabletProximityEventSubtype or an event of type NSTabletProximity.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The vendor-assigned serial number of a pointing device. (read-only)

    Declaration

    Swift

    var pointingDeviceSerialNumber: Int { get }

    Objective-C

    @property(readonly) NSUInteger pointingDeviceSerialNumber

    Discussion

    Devices of different types, such as a puck and a pen, may have the same serial number. This property is valid for mouse events with subtype NSTabletProximityEventSubtype or an event of type NSTabletProximity.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The kind of pointing device associated with this event. (read-only)

    Declaration

    Swift

    var pointingDeviceType: NSPointingDeviceType { get }

    Objective-C

    @property(readonly) NSPointingDeviceType pointingDeviceType

    Discussion

    For example, the device could be a pen, eraser, or cursor pointing device. This property is valid for mouse events with subtype NSTabletProximityEventSubtype and for NSTabletProximity events. See Constants for descriptions of valid NSPointingDeviceType constants.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The index of the tablet device connected to the system. (read-only)

    Declaration

    Swift

    var systemTabletID: Int { get }

    Objective-C

    @property(readonly) NSUInteger systemTabletID

    Discussion

    If multiple tablets are connected to the system, the system-tablet ID is incremented for each subsequent one. If there is only one tablet device, its system-tablet ID is zero. This property is valid for mouse events with the subtype NSTabletProximityEventSubtype or NSTabletProximity events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • tabletID tabletID Property

    The USB model identifier of the tablet device associated with this event. (read-only)

    Declaration

    Swift

    var tabletID: Int { get }

    Objective-C

    @property(readonly) NSUInteger tabletID

    Discussion

    This property is valid for mouse events with subtype NSTabletProximityEventSubtype and for NSTabletProximity events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • uniqueID uniqueID Property

    The unique identifier of the pointing device that generated this event. (read-only)

    Declaration

    Swift

    var uniqueID: UInt64 { get }

    Objective-C

    @property(readonly) unsigned long long uniqueID

    Discussion

    Also known as tool ID, this is a unique number recorded in the chip inside every pointing device. The unique ID makes it possible to assign a specific pointing device to a specific tablet. You can also use it to “sign” documents or to restrict access to document layers to a specific pointing device. This method is valid for mouse events with subtype NSTabletProximityEventSubtype and for NSTabletProximity events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • vendorID vendorID Property

    The vendor identifier of the tablet associated with the event. (read-only)

    Declaration

    Swift

    var vendorID: Int { get }

    Objective-C

    @property(readonly) NSUInteger vendorID

    Discussion

    The tablet is typically a USB device. This method is valid only for mouse events with subtype NSTabletProximityEventSubtype and for NSTabletProximity events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • A coded bit field whose set bits indicate the type of pointing device (within a vendor selection) associated with the event. (read-only)

    Declaration

    Swift

    var vendorPointingDeviceType: Int { get }

    Objective-C

    @property(readonly) NSUInteger vendorPointingDeviceType

    Discussion

    See the vendor documentation for an interpretation of significant bits. This method is valid only for mouse events with subtype NSTabletProximityEventSubtype and for NSTabletProximity events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    See Also

    vendorID

  • absoluteX absoluteX Property

    The absolute x coordinate of a pointing device on its tablet at full tablet resolution. (read-only)

    Declaration

    Swift

    var absoluteX: Int { get }

    Objective-C

    @property(readonly) NSInteger absoluteX

    Discussion

    For the coordinate to be valid, this event must be generated by a tablet pointing device (otherwise the property is set to 0). This property is valid only for mouse events with a subtype of NSTabletPointEventSubtype and for events of type NSTabletPoint. Use this value if you want to scale from tablet location to screen location yourself; otherwise use the class method mouseLocation or the instance method locationInWindow.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • absoluteY absoluteY Property

    The absolute y coordinate of a pointing device on its tablet at full tablet resolution. (read-only)

    Declaration

    Swift

    var absoluteY: Int { get }

    Objective-C

    @property(readonly) NSInteger absoluteY

    Discussion

    For the coordinate to be valid, this event must be generated by a tablet pointing device (otherwise the property is set to 0). This property is valid only for mouse events with a subtype of NSTabletPointEventSubtype and for events of type NSTabletPoint. Use this value if you want to scale from tablet location to screen location yourself; otherwise use the class method mouseLocation or the instance method locationInWindow.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • absoluteZ absoluteZ Property

    The absolute z coordinate of pointing device on its tablet at full tablet resolution. (read-only)

    Declaration

    Swift

    var absoluteZ: Int { get }

    Objective-C

    @property(readonly) NSInteger absoluteZ

    Discussion

    For the coordinate to be valid, this event must be generated by a tablet pointing device (otherwise the property is set to 0). The z coordinate does not represent pressure. It registers the depth coordinate returned by some tablet devices with wheels; if the device is something other than these, 0 is returned. This method is valid only for mouse events with a subtype of NSTabletPointEventSubtype and for events of type NSTabletPoint.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • A bit mask identifying the buttons pressed for a tablet event. (read-only)

    Declaration

    Swift

    var buttonMask: NSEventButtonMask { get }

    Objective-C

    @property(readonly) NSEventButtonMask buttonMask

    Discussion

    Use one or more of the button-mask constants described in Constants to determine which of the pointing device’s buttons are pressed. This property is valid only for mouse events with a subtype of NSTabletPointEventSubtype and for events of type NSTabletPoint; otherwise, the property is set to 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • rotation rotation Property

    The rotation in degrees of the tablet pointing device associated with this event. (read-only)

    Declaration

    Swift

    var rotation: Float { get }

    Objective-C

    @property(readonly) float rotation

    Discussion

    Many devices do not support rotation, in which case the returned value is 0.0. This property is valid only for mouse events with subtype NSTabletPointEventSubtype and for NSTabletPoint events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    See Also

    pressure
    tilt

  • The tangential pressure on the device that generated this event. (read-only)

    Declaration

    Swift

    var tangentialPressure: Float { get }

    Objective-C

    @property(readonly) float tangentialPressure

    Discussion

    The property’s value can range from -1.0 to 1.0. Tangential pressure is also known as barrel pressure. Only some pointing devices support tangential pressure. This method is valid for mouse events with subtype NSTabletPointEventSubtype and for NSTabletPoint events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    See Also

    pressure

  • tilt tilt Property

    The scaled tilt values of the pointing device that generated this event. (read-only)

    Declaration

    Swift

    var tilt: NSPoint { get }

    Objective-C

    @property(readonly) NSPoint tilt

    Discussion

    This property’s value can range from -1.0 to 1.0 for both axes. A negative x-coordinate value indicates a tilt to the left and a positive value indicates a tilt to the right; a negative y-coordinate value indicates a tilt to the top and a positive value indicates a tilt to the bottom. If the device is perfectly perpendicular to the table surface, the values are 0.0 for both axes. This property is valid for mouse events with subtype NSTabletPointEventSubtype and for NSTabletPoint events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    See Also

    pressure
    rotation

  • An array of three vendor-defined NSNumber objects associated with a pointing-type event. (read-only)

    Declaration

    Swift

    var vendorDefined: AnyObject { get }

    Objective-C

    @property(readonly, strong) id vendorDefined

    Discussion

    The NSNumber objects encapsulate short values that vendors may return for various reasons; see the vendor documentation for details.This method is valid for mouse events with subtype NSTabletPointEventSubtype and for NSTabletPoint events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Begins generating periodic events for the current thread.

    Declaration

    Swift

    class func startPeriodicEventsAfterDelay(_ delaySeconds: NSTimeInterval, withPeriod periodSeconds: NSTimeInterval)

    Objective-C

    + (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds withPeriod:(NSTimeInterval)periodSeconds

    Parameters

    delaySeconds

    The number of seconds that NSEvent should wait before beginning to generate periodic events.

    periodSeconds

    The period in seconds between the generated events.

    Discussion

    Raises an NSInternalInconsistencyException if periodic events are already being generated for the current thread. This method is typically used in a modal loop while tracking mouse-dragged events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Stops generating periodic events for the current thread and discards any periodic events remaining in the queue.

    Declaration

    Swift

    class func stopPeriodicEvents()

    Objective-C

    + (void)stopPeriodicEvents

    Discussion

    This message is ignored if periodic events aren’t currently being generated.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The change in magnification. (read-only)

    Declaration

    Swift

    var magnification: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat magnification

    Discussion

    The change in magnification that should be added to the current scaling of an item to achieve the new scale factor. This message is valid only for events of type NSEventTypeMagnify.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns all the NSTouch objects associated with a specific phase.

    Declaration

    Swift

    func touchesMatchingPhase(_ phase: NSTouchPhase, inView view: NSView?) -> Set<NSObject>

    Objective-C

    - (NSSet *)touchesMatchingPhase:(NSTouchPhase)phase inView:(NSView *)view

    Parameters

    phase

    The touch phase for which you want touches. See NSTouchPhase for the possible values.

    view

    The view for which touches are wanted. Touches that target this view, or any of the view’s descendants will be returned. Passing nil as the view gets all touches regardless of their targeted view.

    Return Value

    A set of applicable NSTouch objects.

    Discussion

    This method is only valid for gesture events (gesture, magnify, swipe, rotate, etc.). Using this method a view can get all of the touches associated with a gesture without overriding the individual touch responder methods.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the user's preference about using gesture scrolls as a way to track fluid swipes.

    Declaration

    Swift

    class func isSwipeTrackingFromScrollEventsEnabled() -> Bool

    Objective-C

    + (BOOL)isSwipeTrackingFromScrollEventsEnabled

    Return Value

    YEStrue if swipe tracking for scroll events is enable; otherwise NOfalse.

    Discussion

    This value is determined by the mouse and trackpad preferences for the current user.

    Generally, an NSScrollView instance will check this for you. However, if your app is not using an NSScrollView object, or an NSResponder instance can receive NSScrollWheel messages without first being sent to a scroll view , then you should check this preference before invoking trackSwipeEventWithOptions:dampenAmountThresholdMin:max:usingHandler:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • A Boolean value that indicates whether precise scrolling deltas are available. (read-only)

    Declaration

    Swift

    var hasPreciseScrollingDeltas: Bool { get }

    Objective-C

    @property(readonly) BOOL hasPreciseScrollingDeltas

    Discussion

    This property is set to YEStrue if precise scrolling deltas are available; otherwise, NOfalse.

    This property is valid for NSScrollWheel events. A generic scroll wheel issues rather coarse scroll deltas. Some mice and trackpads provide much more precise delta. This method determines how the values of the scrollingDeltaX and scrollingDeltaY should be interpreted.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • The scroll wheel’s horizontal delta. (read-only)

    Declaration

    Swift

    var scrollingDeltaX: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat scrollingDeltaX

    Discussion

    This is the preferred property for accessing NSScrollWheel delta values. When hasPreciseScrollingDeltas is NOfalse, your application may need to modify the raw value before using it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • The scroll wheel’s vertical delta. (read-only)

    Declaration

    Swift

    var scrollingDeltaY: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat scrollingDeltaY

    Discussion

    This is the preferred property for accessing NSScrollWheel delta values. When hasPreciseScrollingDeltas is NOfalse, multiply the value returned by this method by the line or row height. Otherwise scroll by the returned amount.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • The momentum phase for a scroll or flick gesture. (read-only)

    Declaration

    Swift

    var momentumPhase: NSEventPhase { get }

    Objective-C

    @property(readonly) NSEventPhase momentumPhase

    Discussion

    This property is valid for NSScrollWheel events. With the Magic Mouse and some trackpads, the user can use a scroll wheel or flick gesture resulting in a stream of scroll events that dissipate over time.

    The location of these scroll wheel events changes as the user moves the cursor. These events are attached to the view that is under the cursor when the flick occurs. A custom view can use this method to recognize these momentum scroll events and further route the event to the appropriate sub component.

    See NSEventPhase for possible values.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • phase phase Property

    The phase of a gesture event, such as a magnify, scroll, or pressure change. (read-only)

    Declaration

    Swift

    var phase: NSEventPhase { get }

    Objective-C

    @property(readonly) NSEventPhase phase

    Discussion

    A gesture phase corresponds to a fluid gesture event. As a gesture event occurs, its phase begins with NSEventPhaseBegan and ends with either NSEventPhaseEnded or NSEventPhaseCancelled. All the gesture events are sent to the view under the cursor when the NSEventPhaseBegan occurred.

    A gesture scroll event starts with a NSEventPhaseBegan phase and ends with a NSPhaseEnded.

    A pressure event (type NSEventTypePressure) is a fluid gesture. Like the other fluid gesture events, it has a phase that describes the sequence of the pressure gesture stream.

    Legacy scroll wheel events (say from a Mighty Mouse) and momentum scroll wheel events have a phase of NSEventPhaseNone.

    See NSEventPhase for possible values.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Allows tracking and user interface feedback of scroll wheel events.

    Declaration

    Swift

    func trackSwipeEventWithOptions(_ options: NSEventSwipeTrackingOptions, dampenAmountThresholdMin minDampenThreshold: CGFloat, max maxDampenThreshold: CGFloat, usingHandler trackingHandler: (CGFloat, NSEventPhase, Bool, UnsafeMutablePointer<ObjCBool>) -> Void)

    Objective-C

    - (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options dampenAmountThresholdMin:(CGFloat)minDampenThreshold max:(CGFloat)maxDampenThreshold usingHandler:(void (^)(CGFloat gestureAmount, NSEventPhase phase, BOOL isComplete, BOOL *stop))trackingHandler

    Parameters

    options

    The swipe tracking events. See NSEventSwipeTrackingOptions for possible values.

    minDampenThreshold

    The minimum dampen threshold. This value is considered to encompass the “current view content area” and is referred to as a page. This is the number of pages with a negative position relative to the current page. The value must be less than or equal to zero.

    maxDampenThreshold

    The maximum dampen threshold. This value is considered to encompass the “current view content area” and is referred to as a page. This is the number of pages with a positive position relative to the current page. The value must be greater than or equal to zero.

    trackingHandler

    The Block used as the tracking handler.

    The Block takes four arguments:

    gestureAmount

    The amount of gesture that you should display in the user interface. This may be a fractional amount.

    The direction of the gestureAmount matches the user's "scroll content" preference setting as set in directionInvertedFromDevice, which is based on a user preference.

    Upon completion, the gesture amount will animate to one of the following values: -1, 0, 1.

    phase

    The phase of the physical gesture as performed by the user. See NSEventPhase for possible values. When the phase is either NSEventPhaseEnded, or NSEventPhaseMayBegin, the user has physically ended the gesture successfully or un-successfully, respectively.

    Your handler will continue to be called with updated progress values to complete the fluid swipe animation with a phase of NSEventPhaseNone.

    isComplete

    Signifies the swipe and animation are complete and you should release any temporary animation objects.

    The trackingHandler is released and will not be called further.

    stop

    A reference to a Boolean value. The Block can set the value to YEStrue to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YEStrue within the Block

    Discussion

    Scroll wheel swipes are tracked not only to the end of the physical gesture phase by the user, but also to the completion of any user interface animation that should be performed. Using this method allows your implementation to maintain a consistent fluid feel with other applications. Any gesture amount outside of the supplied minimum and maximum dampen amount is pre-dampened for you to provide an elastic feel.

    The swipe gestureAmount that would fall outside of the range specified by the minDampenThreshold and maxDampenThreshold are automatically dampened. For example, the user’s physical swipe action results in a value of .50, however, there is no page in that direction to swipe to. The gestureAmount reported is adjusted by a damping factor resulting in something like .125. As a developer, you simply treat the gestureAmount like you normally do, and the result is an elastic feedback effect to let the user know that there is nothing to swipe to in that direction.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • A Boolean value that indicates whether the user has changed the device inversion. (read-only)

    Declaration

    Swift

    var directionInvertedFromDevice: Bool { get }

    Objective-C

    @property(getter=isDirectionInvertedFromDevice, readonly) BOOL directionInvertedFromDevice

    Discussion

    This property is set to YEStrue if the direction is inverted; otherwise, NOfalse.

    This property is valid for NSEventScrollWheel and NSEventTypeSwipe events. The user may choose to change the scrolling behavior such that it feels like they are moving the content instead of the scroll bar.

    To accomplish this, deltaX and deltaY and scrollingDeltaX and scrollingDeltaY values are automatically inverted for NSEventScrollWheel events according to the user's preferences.

    The direction of fluid swipes matches the direction of scrolling and as such for NSEventTypeSwipe events gestureAmount is inverted. However, for some uses of NSEventScrollWheel and NSEventTypeSwipe events, the behavior should not respect the user preference. This property allows you to determine when the event has been inverted and compensate by multiplying by -1 if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Returns the location of the receiver in the coordinate system of the given node.

    Declaration

    Swift

    func locationInNode(_ node: SKNode!) -> CGPoint

    Objective-C

    - (CGPoint)locationInNode:(SKNode *)node

    Parameters

    node

    A node that is a descendant of a scene presented in the window that received the mouse event.

    Return Value

    The location of the event in the node’s coordinate system.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in OS X v10.9 and later.

Data Types

  • These constants specify they swipe tracking options.

    Declaration

    Swift

    struct NSEventSwipeTrackingOptions : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var LockDirection: NSEventSwipeTrackingOptions { get } static var ClampGestureAmount: NSEventSwipeTrackingOptions { get } }

    Objective-C

    enum { NSEventSwipeTrackingLockDirection = 0x1 << 0, NSEventSwipeTrackingClampGestureAmount = 0x1 << 1 }; typedef NSUInteger NSEventSwipeTrackingOptions;

    Constants

    • LockDirection

      NSEventSwipeTrackingLockDirection

      Clamp gestureAmount to 0 if the user starts to swipe in the opposite direction than they started.

      Available in OS X v10.7 and later.

    • ClampGestureAmount

      NSEventSwipeTrackingClampGestureAmount

      Don't allow gestureAmount to go beyond +/-1.0

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • These constants specify the gesture tracking axis.

    Declaration

    Swift

    enum NSEventGestureAxis : Int { case None case Horizontal case Vertical }

    Objective-C

    enum { NSEventGestureAxisNone = 0, NSEventGestureAxisHorizontal, NSEventGestureAxisVertical }; typedef NSInteger NSEventGestureAxis;

    Constants

    • None

      NSEventGestureAxisNone

      There is no specific gesture axis.

      Available in OS X v10.7 and later.

    • Horizontal

      NSEventGestureAxisHorizontal

      The gesture axis is horizontal.

      Available in OS X v10.7 and later.

    • Vertical

      NSEventGestureAxisVertical

      The gesture axis is vertical.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • These constants represent the possible phases during an event phase.

    Declaration

    Swift

    struct NSEventPhase : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var None: NSEventPhase { get } static var Began: NSEventPhase { get } static var Stationary: NSEventPhase { get } static var Changed: NSEventPhase { get } static var Ended: NSEventPhase { get } static var Cancelled: NSEventPhase { get } static var MayBegin: NSEventPhase { get } }

    Objective-C

    enum { NSEventPhaseNone = 0, NSEventPhaseBegan = 0x1 << 0, NSEventPhaseStationary = 0x1 << 1, NSEventPhaseChanged = 0x1 << 2, NSEventPhaseEnded = 0x1 << 3, NSEventPhaseCancelled = 0x1 << 4, NSEventPhaseMayBegin = 0x1 << 5 }; #endif typedef NSUInteger NSEventPhase;

    Constants

    • None

      NSEventPhaseNone

      The event is not associated with a phase.

      Available in OS X v10.7 and later.

    • Began

      NSEventPhaseBegan

      An event phase has begun.

      Available in OS X v10.7 and later.

    • Stationary

      NSEventPhaseStationary

      An event phase is in progresses but hasn't moved since the previous event.

      Available in OS X v10.7 and later.

    • Changed

      NSEventPhaseChanged

      An event phase has changed.

      Available in OS X v10.7 and later.

    • Ended

      NSEventPhaseEnded

      The event phase ended..

      Available in OS X v10.7 and later.

    • Cancelled

      NSEventPhaseCancelled

      The system cancelled the event phase.

      Available in OS X v10.7 and later.

    • MayBegin

      NSEventPhaseMayBegin

      The system even phase may begin.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • These constants represent the possible phases during a touch gesture.

    Declaration

    Swift

    struct NSTouchPhase : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var Began: NSTouchPhase { get } static var Moved: NSTouchPhase { get } static var Stationary: NSTouchPhase { get } static var Ended: NSTouchPhase { get } static var Cancelled: NSTouchPhase { get } static var Touching: NSTouchPhase { get } static var Any: NSTouchPhase { get } }

    Objective-C

    enum { NSTouchPhaseBegan = 1 << 0, NSTouchPhaseMoved = 1 << 1, NSTouchPhaseStationary = 1 << 2, NSTouchPhaseEnded = 1 << 3, NSTouchPhaseCancelled = 1 << 4, NSTouchPhaseTouching = NSTouchPhaseBegan | NSTouchPhaseMoved | NSTouchPhaseStationary, NSTouchPhaseAny = NSUIntegerMax }; typedef NSUInteger NSTouchPhase;

    Constants

    • Began

      NSTouchPhaseBegan

      A finger for a given event touched the screen.

      Available in OS X v10.7 and later.

    • Moved

      NSTouchPhaseMoved

      A finger for a given event moved on the screen.

      Available in OS X v10.7 and later.

    • Stationary

      NSTouchPhaseStationary

      A finger is touching the surface but hasn't moved since the previous event.

      Available in OS X v10.7 and later.

    • Ended

      NSTouchPhaseEnded

      A finger for a given event was lifted from the screen.

      Available in OS X v10.7 and later.

    • Cancelled

      NSTouchPhaseCancelled

      The system cancelled tracking for the touch.

      Available in OS X v10.7 and later.

    • Touching

      NSTouchPhaseTouching

      An NSTouchPhaseBegan, or NSTouchPhaseMoved, or NSTouchPhaseStationary phase is in progress.

      Available in OS X v10.7 and later.

    • Any

      NSTouchPhaseAny

      Any touch phase.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Declaration

    Swift

    enum NSEventType : UInt { case LeftMouseDown case LeftMouseUp case RightMouseDown case RightMouseUp case MouseMoved case LeftMouseDragged case RightMouseDragged case MouseEntered case MouseExited case KeyDown case KeyUp case FlagsChanged case AppKitDefined case SystemDefined case ApplicationDefined case Periodic case CursorUpdate case ScrollWheel case TabletPoint case TabletProximity case OtherMouseDown case OtherMouseUp case OtherMouseDragged case EventTypeGesture case EventTypeMagnify case EventTypeSwipe case EventTypeRotate case EventTypeBeginGesture case EventTypeEndGesture case EventTypeSmartMagnify case EventTypeQuickLook case EventTypePressure }

    Objective-C

    enum { NSLeftMouseDown = 1, NSLeftMouseUp = 2, NSRightMouseDown = 3, NSRightMouseUp = 4, NSMouseMoved = 5, NSLeftMouseDragged = 6, NSRightMouseDragged = 7, NSMouseEntered = 8, NSMouseExited = 9, NSKeyDown = 10, NSKeyUp = 11, NSFlagsChanged = 12, NSAppKitDefined = 13, NSSystemDefined = 14, NSApplicationDefined = 15, NSPeriodic = 16, NSCursorUpdate = 17, NSScrollWheel = 22, NSTabletPoint = 23, NSTabletProximity = 24, NSOtherMouseDown = 25, NSOtherMouseUp = 26, NSOtherMouseDragged = 27 NSEventTypeGesture = 29, NSEventTypeMagnify = 30, NSEventTypeSwipe = 31, NSEventTypeRotate = 18, NSEventTypeBeginGesture = 19, NSEventTypeEndGesture = 20 NSEventTypeSmartMagnify = 32, NSEventTypeQuickLook = 33 NSEventTypePressure = 34 }; typedef NSUInteger NSEventType;

    Constants

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • These constants are masks for the events defined in NSEventType. Pass them to the NSCell method sendActionOn: to specify when an NSCell should send its action message.

    Declaration

    Swift

    static var LeftMouseDownMask: NSEventMask { get } static var LeftMouseUpMask: NSEventMask { get } static var RightMouseDownMask: NSEventMask { get } static var RightMouseUpMask: NSEventMask { get } static var OtherMouseDownMask: NSEventMask { get } static var OtherMouseUpMask: NSEventMask { get } static var MouseMovedMask: NSEventMask { get } static var LeftMouseDraggedMask: NSEventMask { get } static var RightMouseDraggedMask: NSEventMask { get } static var OtherMouseDraggedMask: NSEventMask { get } static var MouseEnteredMask: NSEventMask { get } static var MouseExitedMask: NSEventMask { get } static var CursorUpdateMask: NSEventMask { get } static var KeyDownMask: NSEventMask { get } static var KeyUpMask: NSEventMask { get } static var FlagsChangedMask: NSEventMask { get } static var AppKitDefinedMask: NSEventMask { get } static var SystemDefinedMask: NSEventMask { get } static var ApplicationDefinedMask: NSEventMask { get } static var PeriodicMask: NSEventMask { get } static var ScrollWheelMask: NSEventMask { get } static var TabletPointMask: NSEventMask { get } static var TabletProximityMask: NSEventMask { get } static var EventMaskGesture: NSEventMask { get } static var EventMaskMagnify: NSEventMask { get } static var EventMaskSwipe: NSEventMask { get } static var EventMaskRotate: NSEventMask { get } static var EventMaskBeginGesture: NSEventMask { get } static var EventMaskEndGesture: NSEventMask { get } static var EventMaskSmartMagnify: NSEventMask { get } static var EventMaskPressure: NSEventMask { get }

    Objective-C

    enum { NSLeftMouseDownMask = 1 << NSLeftMouseDown, NSLeftMouseUpMask = 1 << NSLeftMouseUp, NSRightMouseDownMask = 1 << NSRightMouseDown, NSRightMouseUpMask = 1 << NSRightMouseUp, NSMouseMovedMask = 1 << NSMouseMoved, NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged, NSRightMouseDraggedMask = 1 << NSRightMouseDragged, NSMouseEnteredMask = 1 << NSMouseEntered, NSMouseExitedMask = 1 << NSMouseExited, NSKeyDownMask = 1 << NSKeyDown, NSKeyUpMask = 1 << NSKeyUp, NSFlagsChangedMask = 1 << NSFlagsChanged, NSAppKitDefinedMask = 1 << NSAppKitDefined, NSSystemDefinedMask = 1 << NSSystemDefined, NSApplicationDefinedMask = 1 << NSApplicationDefined, NSPeriodicMask = 1 << NSPeriodic, NSCursorUpdateMask = 1 << NSCursorUpdate, NSScrollWheelMask = 1 << NSScrollWheel, NSTabletPointMask = 1 << NSTabletPoint, NSTabletProximityMask = 1 << NSTabletProximity, NSOtherMouseDownMask = 1 << NSOtherMouseDown, NSOtherMouseUpMask = 1 << NSOtherMouseUp, NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged, NSEventMaskGesture = 1 << NSEventTypeGesture, NSEventMaskMagnify = 1 << NSEventTypeMagnify, NSEventMaskSwipe = 1U << NSEventTypeSwipe, NSEventMaskRotate = 1 << NSEventTypeRotate, NSEventMaskBeginGesture = 1 << NSEventTypeBeginGesture, NSEventMaskEndGesture = 1 << NSEventTypeEndGesture, NSEventMaskSmartMagnify = 1ULL << NSEventTypeSmartMagnify, NSEventMaskPressure = 1ULL << NSEventTypePressure, NSAnyEventMask = 0xffffffffU }; typedef unsigned long long NSEventMask; NSUInteger NSEventMaskFromType (NSEventType type ) { return (1 << type ); };

    Constants

  • The following constants (except for NSDeviceIndependentModifierFlagsMask) represent device-independent bits found in event modifier flags:

    Declaration

    Swift

    static var AlphaShiftKeyMask: NSEventModifierFlags { get } static var ShiftKeyMask: NSEventModifierFlags { get } static var ControlKeyMask: NSEventModifierFlags { get } static var AlternateKeyMask: NSEventModifierFlags { get } static var CommandKeyMask: NSEventModifierFlags { get } static var NumericPadKeyMask: NSEventModifierFlags { get } static var HelpKeyMask: NSEventModifierFlags { get } static var FunctionKeyMask: NSEventModifierFlags { get } static var DeviceIndependentModifierFlagsMask: NSEventModifierFlags { get }

    Objective-C

    enum { NSAlphaShiftKeyMask = 1 << 16, NSShiftKeyMask = 1 << 17, NSControlKeyMask = 1 << 18, NSAlternateKeyMask = 1 << 19, NSCommandKeyMask = 1 << 20, NSNumericPadKeyMask = 1 << 21, NSHelpKeyMask = 1 << 22, NSFunctionKeyMask = 1 << 23, NSDeviceIndependentModifierFlagsMask = 0xffff0000U };

    Constants

    • AlphaShiftKeyMask

      NSAlphaShiftKeyMask

      Set if Caps Lock key is pressed.

      Available in OS X v10.0 and later.

    • ShiftKeyMask

      NSShiftKeyMask

      Set if Shift key is pressed.

      Available in OS X v10.0 and later.

    • ControlKeyMask

      NSControlKeyMask

      Set if Control key is pressed.

      Available in OS X v10.0 and later.

    • AlternateKeyMask

      NSAlternateKeyMask

      Set if Option or Alternate key is pressed.

      Available in OS X v10.0 and later.

    • CommandKeyMask

      NSCommandKeyMask

      Set if Command key is pressed.

      Available in OS X v10.0 and later.

    • NumericPadKeyMask

      NSNumericPadKeyMask

      Set if any key in the numeric keypad is pressed. The numeric keypad is generally on the right side of the keyboard. This is also set if any of the arrow keys are pressed (NSUpArrowFunctionKey, NSDownArrowFunctionKey, NSLeftArrowFunctionKey, and NSRightArrowFunctionKey).

      Available in OS X v10.0 and later.

    • HelpKeyMask

      NSHelpKeyMask

      Set if the Help key is pressed.

      Available in OS X v10.0 and later.

    • FunctionKeyMask

      NSFunctionKeyMask

      Set if any function key is pressed. The function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys).

      Available in OS X v10.0 and later.

    • DeviceIndependentModifierFlagsMask

      NSDeviceIndependentModifierFlagsMask

      Used to retrieve only the device-independent modifier flags, allowing applications to mask off the device-dependent modifier flags, including event coalescing information.

      Available in OS X v10.4 and later.

  • The following constants represent pointing-device types for NSTabletProximity events or mouse events with subtype NSTabletProximityEventSubtype. The pointingDeviceType property returns one of these constants.

    Declaration

    Swift

    enum NSPointingDeviceType : UInt { case UnknownPointingDevice case PenPointingDevice case CursorPointingDevice case EraserPointingDevice }

    Objective-C

    typedef enum { NSUnknownPointingDevice = NX_TABLET_POINTER_UNKNOWN, NSPenPointingDevice = NX_TABLET_POINTER_PEN, NSCursorPointingDevice = NX_TABLET_POINTER_CURSOR, NSEraserPointingDevice = NX_TABLET_POINTER_ERASER } NSPointingDeviceType;

    Constants

    • UnknownPointingDevice

      NSUnknownPointingDevice

      Represents an unknown type of pointing device.

      Available in OS X v10.4 and later.

    • PenPointingDevice

      NSPenPointingDevice

      Represents the tip end of a stylus-like pointing device.

      Available in OS X v10.4 and later.

    • CursorPointingDevice

      NSCursorPointingDevice

      Represents a cursor (or puck-like) pointing device.

      Available in OS X v10.4 and later.

    • EraserPointingDevice

      NSEraserPointingDevice

      Represents the eraser end of a stylus-like pointing device.

      Available in OS X v10.4 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The following constants represent mouse-event subtypes for mouse and tablet events (accessed with the subtype property).

    Declaration

    Swift

    case NSTouchEventSubtype

    Objective-C

    enum { NSMouseEventSubtype = NX_SUBTYPE_DEFAULT, NSTabletPointEventSubtype = NX_SUBTYPE_TABLET_POINT, NSTabletProximityEventSubtype = NX_SUBTYPE_TABLET_PROXIMITY NSTouchEventSubtype = NX_SUBTYPE_MOUSE_TOUCH };

    Constants

    • NSMouseEventSubtype

      NSMouseEventSubtype

      Indicates a purely mouse event.

      Available in OS X v10.4 and later.

    • NSTabletPointEventSubtype

      NSTabletPointEventSubtype

      Indicates a tablet-pointer event; see description of NSTabletPoint.

      Available in OS X v10.4 and later.

    • NSTabletProximityEventSubtype

      NSTabletProximityEventSubtype

      Indicates a tablet-proximity event; see description of NSTabletProximity.

      Available in OS X v10.4 and later.

    • NSTouchEventSubtype

      NSTouchEventSubtype

      Indicates a touch event subtype.

      Available in OS X v10.6 and later.

  • The following constants represent button masks for NSTabletPoint events or mouse events with subtype NSTabletPointEventSubtype. The buttonMask property returns a bit mask, which you test with one or more of these constants to determine the state of the buttons on a tablet pointing device.

    Declaration

    Swift

    static var PenTipMask: NSEventButtonMask { get } static var PenLowerSideMask: NSEventButtonMask { get } static var PenUpperSideMask: NSEventButtonMask { get }

    Objective-C

    enum { NSPenTipMask = NX_TABLET_BUTTON_PENTIPMASK, NSPenLowerSideMask = NX_TABLET_BUTTON_PENLOWERSIDEMASK, NSPenUpperSideMask = NX_TABLET_BUTTON_PENUPPERSIDEMASK };

    Constants

    • PenTipMask

      NSPenTipMask

      The pen tip is activated.

      Available in OS X v10.4 and later.

    • PenLowerSideMask

      NSPenLowerSideMask

      The button on the lower side of the device is activated.

      Available in OS X v10.4 and later.

    • PenUpperSideMask

      NSPenUpperSideMask

      The button on the upper side of the device is activated.

      Available in OS X v10.4 and later.

  • These constants represent the types of events defined by the Application Kit.

    Declaration

    Swift

    case NSWindowExposedEventType case NSApplicationActivatedEventType case NSApplicationDeactivatedEventType case NSWindowMovedEventType case NSScreenChangedEventType case NSAWTEventType

    Objective-C

    enum { NSWindowExposedEventType = 0, NSApplicationActivatedEventType = 1, NSApplicationDeactivatedEventType = 2, NSWindowMovedEventType = 4, NSScreenChangedEventType = 8, NSAWTEventType = 16 };

    Constants

    • NSWindowExposedEventType

      NSWindowExposedEventType

      A non-retained NSWindow has been exposed.

      Available in OS X v10.0 and later.

    • NSApplicationActivatedEventType

      NSApplicationActivatedEventType

      The application has been activated.

      Available in OS X v10.0 and later.

    • NSApplicationDeactivatedEventType

      NSApplicationDeactivatedEventType

      The application has been deactivated.

      Available in OS X v10.0 and later.

    • NSWindowMovedEventType

      NSWindowMovedEventType

      An NSWindow has moved.

      Available in OS X v10.0 and later.

    • NSScreenChangedEventType

      NSScreenChangedEventType

      An NSWindow has changed screens.

      Available in OS X v10.0 and later.

    • NSAWTEventType

      NSAWTEventType

      An event type used to support Java applications.

      Available in OS X v10.0 and later.

  • This constant denotes that the user is turning off the computer.

    Declaration

    Objective-C

    enum { NSPowerOffEventType = 1 };

    Constants

    • NSPowerOffEventType

      NSPowerOffEventType

      Specifies that the user is turning off the computer.

      Available in OS X v10.0 and later.

  • These constants represent Unicode characters (0xF700–0xF8FF) that are reserved for function keys on the keyboard. Combined in NSStrings, they represent values that can be used with the characters and charactersIgnoringModifiers properties and may be used in some parameters in the NSEvent method keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:.

    Declaration

    Swift

    var NSUpArrowFunctionKey: Int { get } var NSDownArrowFunctionKey: Int { get } var NSLeftArrowFunctionKey: Int { get } var NSRightArrowFunctionKey: Int { get } var NSF1FunctionKey: Int { get } var NSF2FunctionKey: Int { get } var NSF3FunctionKey: Int { get } var NSF4FunctionKey: Int { get } var NSF5FunctionKey: Int { get } var NSF6FunctionKey: Int { get } var NSF7FunctionKey: Int { get } var NSF8FunctionKey: Int { get } var NSF9FunctionKey: Int { get } var NSF10FunctionKey: Int { get } var NSF11FunctionKey: Int { get } var NSF12FunctionKey: Int { get } var NSF13FunctionKey: Int { get } var NSF14FunctionKey: Int { get } var NSF15FunctionKey: Int { get } var NSF16FunctionKey: Int { get } var NSF17FunctionKey: Int { get } var NSF18FunctionKey: Int { get } var NSF19FunctionKey: Int { get } var NSF20FunctionKey: Int { get } var NSF21FunctionKey: Int { get } var NSF22FunctionKey: Int { get } var NSF23FunctionKey: Int { get } var NSF24FunctionKey: Int { get } var NSF25FunctionKey: Int { get } var NSF26FunctionKey: Int { get } var NSF27FunctionKey: Int { get } var NSF28FunctionKey: Int { get } var NSF29FunctionKey: Int { get } var NSF30FunctionKey: Int { get } var NSF31FunctionKey: Int { get } var NSF32FunctionKey: Int { get } var NSF33FunctionKey: Int { get } var NSF34FunctionKey: Int { get } var NSF35FunctionKey: Int { get } var NSInsertFunctionKey: Int { get } var NSDeleteFunctionKey: Int { get } var NSHomeFunctionKey: Int { get } var NSBeginFunctionKey: Int { get } var NSEndFunctionKey: Int { get } var NSPageUpFunctionKey: Int { get } var NSPageDownFunctionKey: Int { get } var NSPrintScreenFunctionKey: Int { get } var NSScrollLockFunctionKey: Int { get } var NSPauseFunctionKey: Int { get } var NSSysReqFunctionKey: Int { get } var NSBreakFunctionKey: Int { get } var NSResetFunctionKey: Int { get } var NSStopFunctionKey: Int { get } var NSMenuFunctionKey: Int { get } var NSUserFunctionKey: Int { get } var NSSystemFunctionKey: Int { get } var NSPrintFunctionKey: Int { get } var NSClearLineFunctionKey: Int { get } var NSClearDisplayFunctionKey: Int { get } var NSInsertLineFunctionKey: Int { get } var NSDeleteLineFunctionKey: Int { get } var NSInsertCharFunctionKey: Int { get } var NSDeleteCharFunctionKey: Int { get } var NSPrevFunctionKey: Int { get } var NSNextFunctionKey: Int { get } var NSSelectFunctionKey: Int { get } var NSExecuteFunctionKey: Int { get } var NSUndoFunctionKey: Int { get } var NSRedoFunctionKey: Int { get } var NSFindFunctionKey: Int { get } var NSHelpFunctionKey: Int { get } var NSModeSwitchFunctionKey: Int { get }

    Objective-C

    enum { NSUpArrowFunctionKey = 0xF700, NSDownArrowFunctionKey = 0xF701, NSLeftArrowFunctionKey = 0xF702, NSRightArrowFunctionKey = 0xF703, NSF1FunctionKey = 0xF704, NSF2FunctionKey = 0xF705, NSF3FunctionKey = 0xF706, NSF4FunctionKey = 0xF707, NSF5FunctionKey = 0xF708, NSF6FunctionKey = 0xF709, NSF7FunctionKey = 0xF70A, NSF8FunctionKey = 0xF70B, NSF9FunctionKey = 0xF70C, NSF10FunctionKey = 0xF70D, NSF11FunctionKey = 0xF70E, NSF12FunctionKey = 0xF70F, NSF13FunctionKey = 0xF710, NSF14FunctionKey = 0xF711, NSF15FunctionKey = 0xF712, NSF16FunctionKey = 0xF713, NSF17FunctionKey = 0xF714, NSF18FunctionKey = 0xF715, NSF19FunctionKey = 0xF716, NSF20FunctionKey = 0xF717, NSF21FunctionKey = 0xF718, NSF22FunctionKey = 0xF719, NSF23FunctionKey = 0xF71A, NSF24FunctionKey = 0xF71B, NSF25FunctionKey = 0xF71C, NSF26FunctionKey = 0xF71D, NSF27FunctionKey = 0xF71E, NSF28FunctionKey = 0xF71F, NSF29FunctionKey = 0xF720, NSF30FunctionKey = 0xF721, NSF31FunctionKey = 0xF722, NSF32FunctionKey = 0xF723, NSF33FunctionKey = 0xF724, NSF34FunctionKey = 0xF725, NSF35FunctionKey = 0xF726, NSInsertFunctionKey = 0xF727, NSDeleteFunctionKey = 0xF728, NSHomeFunctionKey = 0xF729, NSBeginFunctionKey = 0xF72A, NSEndFunctionKey = 0xF72B, NSPageUpFunctionKey = 0xF72C, NSPageDownFunctionKey = 0xF72D, NSPrintScreenFunctionKey = 0xF72E, NSScrollLockFunctionKey = 0xF72F, NSPauseFunctionKey = 0xF730, NSSysReqFunctionKey = 0xF731, NSBreakFunctionKey = 0xF732, NSResetFunctionKey = 0xF733, NSStopFunctionKey = 0xF734, NSMenuFunctionKey = 0xF735, NSUserFunctionKey = 0xF736, NSSystemFunctionKey = 0xF737, NSPrintFunctionKey = 0xF738, NSClearLineFunctionKey = 0xF739, NSClearDisplayFunctionKey = 0xF73A, NSInsertLineFunctionKey = 0xF73B, NSDeleteLineFunctionKey = 0xF73C, NSInsertCharFunctionKey = 0xF73D, NSDeleteCharFunctionKey = 0xF73E, NSPrevFunctionKey = 0xF73F, NSNextFunctionKey = 0xF740, NSSelectFunctionKey = 0xF741, NSExecuteFunctionKey = 0xF742, NSUndoFunctionKey = 0xF743, NSRedoFunctionKey = 0xF744, NSFindFunctionKey = 0xF745, NSHelpFunctionKey = 0xF746, NSModeSwitchFunctionKey = 0xF747 };

    Constants

    • NSUpArrowFunctionKey

      NSUpArrowFunctionKey

      Up Arrow key.

      Available in OS X v10.0 and later.

    • NSDownArrowFunctionKey

      NSDownArrowFunctionKey

      Down Arrow key.

      Available in OS X v10.0 and later.

    • NSLeftArrowFunctionKey

      NSLeftArrowFunctionKey

      Left Arrow key.

      Available in OS X v10.0 and later.

    • NSRightArrowFunctionKey

      NSRightArrowFunctionKey

      Right Arrow key.

      Available in OS X v10.0 and later.

    • NSF1FunctionKey

      NSF1FunctionKey

      F1 key.

      Available in OS X v10.0 and later.

    • NSF2FunctionKey

      NSF2FunctionKey

      F2 key.

      Available in OS X v10.0 and later.

    • NSF3FunctionKey

      NSF3FunctionKey

      F3 key.

      Available in OS X v10.0 and later.

    • NSF4FunctionKey

      NSF4FunctionKey

      F4 key.

      Available in OS X v10.0 and later.

    • NSF5FunctionKey

      NSF5FunctionKey

      F5 key.

      Available in OS X v10.0 and later.

    • NSF6FunctionKey

      NSF6FunctionKey

      F6 key.

      Available in OS X v10.0 and later.

    • NSF7FunctionKey

      NSF7FunctionKey

      F7 key.

      Available in OS X v10.0 and later.

    • NSF8FunctionKey

      NSF8FunctionKey

      F8 key.

      Available in OS X v10.0 and later.

    • NSF9FunctionKey

      NSF9FunctionKey

      F9 key.

      Available in OS X v10.0 and later.

    • NSF10FunctionKey

      NSF10FunctionKey

      F10 key.

      Available in OS X v10.0 and later.

    • NSF11FunctionKey

      NSF11FunctionKey

      F11 key.

      Available in OS X v10.0 and later.

    • NSF12FunctionKey

      NSF12FunctionKey

      F12 key.

      Available in OS X v10.0 and later.

    • NSF13FunctionKey

      NSF13FunctionKey

      F13 key.

      Available in OS X v10.0 and later.

    • NSF14FunctionKey

      NSF14FunctionKey

      F14 key.

      Available in OS X v10.0 and later.

    • NSF15FunctionKey

      NSF15FunctionKey

      F15 key.

      Available in OS X v10.0 and later.

    • NSF16FunctionKey

      NSF16FunctionKey

      F16 key.

      Available in OS X v10.0 and later.

    • NSF17FunctionKey

      NSF17FunctionKey

      F17 key.

      Available in OS X v10.0 and later.

    • NSF18FunctionKey

      NSF18FunctionKey

      F18 key.

      Available in OS X v10.0 and later.

    • NSF19FunctionKey

      NSF19FunctionKey

      F19 key.

      Available in OS X v10.0 and later.

    • NSF20FunctionKey

      NSF20FunctionKey

      F20 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF21FunctionKey

      NSF21FunctionKey

      F21 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF22FunctionKey

      NSF22FunctionKey

      F22 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF23FunctionKey

      NSF23FunctionKey

      F23 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF24FunctionKey

      NSF24FunctionKey

      F24 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF25FunctionKey

      NSF25FunctionKey

      F25 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF26FunctionKey

      NSF26FunctionKey

      F26 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF27FunctionKey

      NSF27FunctionKey

      F27 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF28FunctionKey

      NSF28FunctionKey

      F28 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF29FunctionKey

      NSF29FunctionKey

      F29 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF30FunctionKey

      NSF30FunctionKey

      F30 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF31FunctionKey

      NSF31FunctionKey

      F31 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF32FunctionKey

      NSF32FunctionKey

      F32 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF33FunctionKey

      NSF33FunctionKey

      F33 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF34FunctionKey

      NSF34FunctionKey

      F34 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSF35FunctionKey

      NSF35FunctionKey

      F35 key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSInsertFunctionKey

      NSInsertFunctionKey

      Insert key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSDeleteFunctionKey

      NSDeleteFunctionKey

      Forward Delete key.

      Available in OS X v10.0 and later.

    • NSHomeFunctionKey

      NSHomeFunctionKey

      Home key.

      Available in OS X v10.0 and later.

    • NSBeginFunctionKey

      NSBeginFunctionKey

      Begin key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSEndFunctionKey

      NSEndFunctionKey

      End key.

      Available in OS X v10.0 and later.

    • NSPageUpFunctionKey

      NSPageUpFunctionKey

      Page Up key.

      Available in OS X v10.0 and later.

    • NSPageDownFunctionKey

      NSPageDownFunctionKey

      Page Down key.

      Available in OS X v10.0 and later.

    • NSPrintScreenFunctionKey

      NSPrintScreenFunctionKey

      Print Screen key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSScrollLockFunctionKey

      NSScrollLockFunctionKey

      Scroll Lock key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSPauseFunctionKey

      NSPauseFunctionKey

      Pause key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSSysReqFunctionKey

      NSSysReqFunctionKey

      System Request key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSBreakFunctionKey

      NSBreakFunctionKey

      Break key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSResetFunctionKey

      NSResetFunctionKey

      Reset key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSStopFunctionKey

      NSStopFunctionKey

      Stop key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSMenuFunctionKey

      NSMenuFunctionKey

      Menu key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSUserFunctionKey

      NSUserFunctionKey

      User key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSSystemFunctionKey

      NSSystemFunctionKey

      System key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSPrintFunctionKey

      NSPrintFunctionKey

      Print key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSClearLineFunctionKey

      NSClearLineFunctionKey

      Clear/Num Lock key.

      Available in OS X v10.0 and later.

    • NSClearDisplayFunctionKey

      NSClearDisplayFunctionKey

      Clear Display key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSInsertLineFunctionKey

      NSInsertLineFunctionKey

      Insert Line key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSDeleteLineFunctionKey

      NSDeleteLineFunctionKey

      Delete Line key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSInsertCharFunctionKey

      NSInsertCharFunctionKey

      Insert Character key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSDeleteCharFunctionKey

      NSDeleteCharFunctionKey

      Delete Character key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSPrevFunctionKey

      NSPrevFunctionKey

      Previous key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSNextFunctionKey

      NSNextFunctionKey

      Next key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSSelectFunctionKey

      NSSelectFunctionKey

      Select key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSExecuteFunctionKey

      NSExecuteFunctionKey

      Execute key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSUndoFunctionKey

      NSUndoFunctionKey

      Undo key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSRedoFunctionKey

      NSRedoFunctionKey

      Redo key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSFindFunctionKey

      NSFindFunctionKey

      Find key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    • NSHelpFunctionKey

      NSHelpFunctionKey

      Help key.

      Available in OS X v10.0 and later.

    • NSModeSwitchFunctionKey

      NSModeSwitchFunctionKey

      Mode Switch key. Not on most Macintosh keyboards.

      Available in OS X v10.0 and later.

    Discussion

    Note that some function keys are handled at a lower level and are never seen by your application. They include the Volume Up key, Volume Down key, Volume Mute key, Eject key, and Function key found on many iBook and PowerBook computers.