Up
Authors
- Scott Christley (
scottc@net-community.com)
-
- Ovidiu Predescu (
ovidiu@net-community.com)
-
- Felipe A. Rodriguez (
far@ix.netcom.com)
-
Date: Generated at 2025-12-03
The event class
Copyright: (C) 1996 Free Software Foundation, Inc.
- Declared in:
- AppKit/NSEvent.h
- Conforms to:
- NSCoding
- NSCopying
Availability: OpenStep
NSEvent encapsulates information about user
interactions (mouse clicks, key presses, mouse
movement) and system notifications (application
lifecycle, window changes). It serves as the
primary mechanism for delivering input events to
applications and provides detailed information
about the context and nature of each event. Key
features include: - Complete event information
including type, location, timing, and modifiers -
Factory methods for creating events of different
types - Access to event-specific data like click
counts, key codes, and pressure values - Support for
mouse tracking, keyboard input, and system
notifications - Integration with the event loop
and event dispatch system - Tablet and touch input
support for advanced input devices Event Creation:
NSEvent provides class methods to create events for
different purposes: - mouseEventWithType:... for
mouse events with click counts and pressure -
keyEventWithType:... for keyboard events
with character and modifier info -
enterExitEventWithType:... for
mouse tracking events - otherEventWithType:... for
custom and system events Event Properties: All events
have common properties like type, timestamp, location,
and modifiers. Specific event types provide additional
information: - Mouse events: button number,
click count, pressure, scroll deltas - Key events:
character strings, key codes, repeat status -
Tracking events: tracking numbers and user data -
System events: subtype and custom data values The
event data is stored in a union structure that
efficiently manages different data types for
different event categories, minimizing memory usage
while providing type-safe access to event-specific
information.
NSEvent declares 7 Instance Variables
+ (
NSTimeInterval)
doubleClickInterval;
Availability: MacOS-X 10.6.0
Returns the double-click time interval. This is the
maximum time interval between two mouse clicks for
them to be considered a double-click. This value
reflects the user's system preferences. Returns:
The double-click interval in seconds
+ (
NSEvent*)
enterExitEventWithType: (
NSEventType)type
location: (
NSPoint)location
modifierFlags: (
NSUInteger)flags
timestamp: (
NSTimeInterval)time
windowNumber: (
NSInteger)windowNum
context: (
NSGraphicsContext*)context
eventNumber: (
NSInteger)eventNum
trackingNumber: (
NSInteger)trackingNum
userData: (void*)userData;
Availability: OpenStep
Creates an enter/exit event for mouse tracking
areas. This factory method creates events that are
generated when the mouse enters or exits defined
tracking areas within views. These events are used
to implement cursor changes, tooltips, and other
location- sensitive interface behaviors. type:
The event type (NSMouseEntered or
NSMouseExited) location: The mouse
location in window coordinates flags:
Modifier key flags active when the
event occurred time: The time when the
event occurred (seconds since system startup)
windowNum: The window number where the event
occurred context: The graphics context
associated with the window eventNum: Sequential
event number for tracking trackingNum: The tracking
area number that generated this event userData:
User-defined data associated with the tracking
area Returns: A new NSEvent object representing the
enter/exit event
+ (
NSEvent*)
eventWithEventRef: (const void*)eventRef;
Availability: MacOS-X 10.5.0
Creates an NSEvent from a Carbon EventRef. This
factory method creates an NSEvent object from a
Carbon EventRef, allowing integration with Carbon
event handling code. eventRef: A Carbon EventRef to
convert to an NSEvent Returns: A new NSEvent object
representing the Carbon event
+ (BOOL)
isMouseCoalescingEnabled;
Availability: MacOS-X 10.5.0
Returns whether mouse event coalescing is currently
enabled. Mouse coalescing combines multiple rapid
mouse movement events into single events to improve
performance during mouse tracking operations.
Returns: YES if mouse coalescing is
enabled, NO otherwise
+ (
NSEvent*)
keyEventWithType: (
NSEventType)type
location: (
NSPoint)location
modifierFlags: (
NSUInteger)flags
timestamp: (
NSTimeInterval)time
windowNumber: (
NSInteger)windowNum
context: (
NSGraphicsContext*)context
characters: (
NSString*)keys
charactersIgnoringModifiers: (
NSString*)ukeys
isARepeat: (BOOL)repeatKey
keyCode: (unsigned short)code;
Availability: OpenStep
Creates a keyboard event for key presses and
releases. This factory method creates events
representing keyboard input, including both
the actual characters generated and the raw key codes.
It handles modifier key combinations and key repeat
detection. type: The event type
(NSKeyDown or NSKeyUp) location: The mouse
location when the key event occurred
flags: Modifier key flags active when the
key was pressed time: The time when the
event occurred (seconds since system startup)
windowNum: The window number where the event
occurred context: The graphics context
associated with the window keys: The characters
generated by this key press with modifiers ukeys:
The characters that would be generated without
modifiers repeatKey: YES if this is
a repeating key event, NO for initial press
code: The hardware-specific key code for
the pressed key Returns: A new NSEvent object
representing the keyboard event
+ (
NSTimeInterval)
keyRepeatDelay;
Availability: MacOS-X 10.6.0
Returns the key repeat delay interval. This is the
time interval between the initial key press and the
first key repeat event when a key is held down.
Returns: The key repeat delay in seconds
+ (
NSTimeInterval)
keyRepeatInterval;
Availability: MacOS-X 10.6.0
Returns the key repeat interval. This is the time
interval between consecutive key repeat events
after the initial delay when a key is held down.
Returns: The key repeat interval in seconds
+ (
NSEventModifierFlags)
modifierFlags;
Availability: MacOS-X 10.6.0
Returns the currently pressed modifier flags. This
class method returns the modifier flags that are
currently active system-wide, regardless of which
application has focus. This is useful for
checking modifier state outside of event handling.
Returns: The currently active modifier flags
+ (
NSEvent*)
mouseEventWithType: (
NSEventType)type
location: (
NSPoint)location
modifierFlags: (
NSUInteger)flags
timestamp: (
NSTimeInterval)time
windowNumber: (
NSInteger)windowNum
context: (
NSGraphicsContext*)context
eventNumber: (
NSInteger)eventNum
clickCount: (
NSInteger)clickNum
pressure: (float)pressureValue;
Availability: OpenStep
Creates a mouse event for clicks, releases, and
movement. This factory method creates events
representing mouse interactions including
button presses, releases, and movement. It supports
multi-click detection and pressure-sensitive
input devices. type: The event type
(NSLeftMouseDown, NSMouseMoved, etc.)
location: The mouse location in window
coordinates flags: Modifier key
flags active when the event occurred time:
The time when the event occurred (seconds
since system startup) windowNum: The window number
where the event occurred context: The graphics
context associated with the window
eventNum: Sequential event number for tracking
clickNum: Number of clicks (1=single, 2=double,
3=triple, etc.) pressureValue: Pressure value for
pressure-sensitive devices (0.0 to 1.0)
Returns: A new NSEvent object representing the
mouse event
+ (
NSEvent*)
mouseEventWithType: (
NSEventType)type
location: (
NSPoint)location
modifierFlags: (
NSUInteger)flags
timestamp: (
NSTimeInterval)time
windowNumber: (
NSInteger)windowNum
context: (
NSGraphicsContext*)context
eventNumber: (
NSInteger)eventNum
clickCount: (
NSInteger)clickNum
pressure: (float)pressureValue
buttonNumber: (
NSInteger)buttonNum
deltaX: (CGFloat)deltaX
deltaY: (CGFloat)deltaY
deltaZ: (CGFloat)deltaZ;
Availability: Not in OpenStep/MacOS-X
Creates an extended mouse event with additional
button and delta information. This GNUstep-specific
factory method creates mouse events with support
for additional mouse buttons and scroll delta values.
This provides more detailed information than the
standard mouse event creation method. type: The
event type (mouse-related events)
location: The mouse location in window
coordinates flags: Modifier key
flags active when the event occurred time:
The time when the event occurred (seconds
since system startup) windowNum: The window number
where the event occurred context: The graphics
context associated with the window
eventNum: Sequential event number for tracking
clickNum: Number of clicks for button events
pressureValue: Pressure value for
pressure-sensitive devices buttonNum:
The specific mouse button number (0=left, 1=right,
2=middle, etc.) deltaX: Horizontal scroll delta
for scroll events deltaY: Vertical scroll delta for
scroll events deltaZ: Z-axis scroll delta for 3D
scroll devices Returns: A new NSEvent object with
extended mouse information
+ (
NSPoint)
mouseLocation;
Availability: OpenStep
Returns the current mouse location in screen
coordinates. This class method provides the
current mouse cursor position relative to the
screen's coordinate system, regardless of which
window or application currently has focus. Returns:
The current mouse location in screen coordinates
Returns the current mouse location.
+ (
NSEvent*)
otherEventWithType: (
NSEventType)type
location: (
NSPoint)location
modifierFlags: (
NSUInteger)flags
timestamp: (
NSTimeInterval)time
windowNumber: (
NSInteger)windowNum
context: (
NSGraphicsContext*)context
subtype: (short)subType
data1: (
NSInteger)data1
data2: (
NSInteger)data2;
Availability: OpenStep
Creates a system or application-defined event. This
factory method creates events for system
notifications and custom application events.
These events carry custom data and can be used for
inter-component communication within
applications. type: The event type
(NSSystemDefined, NSApplicationDefined,
etc.) location: The location associated
with this event (may be irrelevant) flags: Modifier
key flags active when the event was created
time: The time when the event occurred
(seconds since system startup) windowNum: The
window number associated with this event (may be 0)
context: The graphics context (may be
nil for non-window events) subType:
Event subtype for categorizing similar events data1:
First custom data value data2: Second custom data
value Returns: A new NSEvent object representing the
custom event
+ (
NSUInteger)
pressedMouseButtons;
Availability: MacOS-X 10.6.0
Returns a bitmask of currently pressed mouse
buttons. This class method returns which mouse
buttons are currently pressed system-wide. The
bitmask uses the same format as buttonMask.
Returns: A bitmask indicating which mouse buttons
are pressed
+ (void)
setMouseCoalescingEnabled: (BOOL)flag;
Availability: MacOS-X 10.5.0
Enables or disables mouse event coalescing. When
enabled, multiple mouse moved events that occur in
rapid succession are coalesced into a single event to
improve performance. This is typically desirable
for tracking mouse movement. flag: YES to
enable coalescing, NO to disable
Not implemented (as of 2025-12-03).
Please help us by producing an implementation of
this and donating it to the GNUstep project.
+ (void)
startPeriodicEventsAfterDelay: (
NSTimeInterval)delaySeconds
withPeriod: (
NSTimeInterval)periodSeconds;
Availability: OpenStep
Starts generating periodic events at regular
intervals. This class method configures the
event system to generate NSPeriodic events at
specified intervals. These events can be used for
regular updates, animations, or periodic
processing. The events continue until
stopPeriodicEvents is called.
delaySeconds: Initial delay before the first
periodic event periodSeconds: Time interval
between subsequent periodic events
+ (void)
stopPeriodicEvents;
Availability: OpenStep
Stops generating periodic events. This class method
stops the generation of NSPeriodic events that were
started with
startPeriodicEventsAfterDelay:withPeriod:.
After calling this method, no more periodic events
will be generated.
- (
NSInteger)
absoluteX;
Availability: MacOS-X 10.4.0
Returns the absolute X coordinate for tablet
events. For tablet events, this returns the
absolute position on the tablet surface rather
than the relative screen position. The coordinate
system is tablet-specific. Returns: The absolute X
coordinate on the tablet surface
- (
NSInteger)
absoluteY;
Availability: MacOS-X 10.4.0
Returns the absolute Y coordinate for tablet
events. For tablet events, this returns the
absolute position on the tablet surface rather
than the relative screen position. The coordinate
system is tablet-specific. Returns: The absolute Y
coordinate on the tablet surface
- (
NSInteger)
absoluteZ;
Availability: MacOS-X 10.4.0
Returns the absolute Z coordinate for tablet
events. For 3D tablet events, this returns the
height above the tablet surface. Most 2D tablets
return 0 for this value. Returns: The absolute Z
coordinate (height) above the tablet surface
- (
NSEventMask)
associatedEventsMask;
Availability: MacOS-X 10.3.0
Returns the event mask for events associated with
this event. For tablet proximity events, this returns
a mask indicating which types of events will be generated
by the tablet device when it enters proximity. This
allows applications to prepare for the types of
events they will receive. Returns: An NSEventMask
indicating associated event types
- (
NSEventButtonMask)
buttonMask;
Availability: MacOS-X 10.4.0
Returns a bitmask of currently pressed mouse
buttons. This bitmask indicates which mouse
buttons are currently pressed at the time this
event occurred, not just the button that changed
state for this particular event. Returns: An
NSEventButtonMask indicating which
buttons are pressed
- (
NSInteger)
buttonNumber;
Availability: MacOS-X 10.0.0
Returns the mouse button number for mouse events.
For mouse button events, this returns which button was
pressed or released. Button numbers are: 0=left
button, 1=right button, 2=middle button, etc. For
non-mouse events, the return value is undefined.
Returns: The button number that triggered this
mouse event
Returns the button number for the
mouse button pressed in a mouse event. Intended
primarily for the case where a mouse has three or
more buttons, and you want to know which button an
'other' mouse event refers to.
- (
NSUInteger)
capabilityMask;
Availability: MacOS-X 10.4.0
Returns the capability mask for tablet devices. For
tablet proximity events, this indicates the
capabilities of the tablet device (pressure
sensitivity, tilt, rotation, etc.).
Applications can use this to adapt their
behavior to the device. Returns: A bitmask
indicating the device capabilities
- (
NSString*)
characters;
Availability: OpenStep
Returns the characters generated by a key event.
For keyboard events, this returns the string that would
be inserted into a text field, taking into account the
current modifier keys. For non-keyboard events,
returns nil. Returns: The characters
generated by this key event with modifiers
applied
Returns the string of characters for
a keyboard event.
Raises an
NSInternalInconsistencyException
if applied to any other type of event.
- (
NSString*)
charactersIgnoringModifiers;
Availability: OpenStep
Returns the characters that would be generated
without modifier keys. For keyboard events, this
returns the string that would be generated if no
modifier keys (except Shift for capitalization)
were pressed. This is useful for key binding systems
that want to ignore modifiers. For non-keyboard
events, returns nil. Returns: The base
characters for this key event without modifier
effects
Returns the string of characters for
a keyboard event, as if no modifier keys had been pressed
when the keyboard event occirred.
Raises an
NSInternalInconsistencyException
if applied to any other type of event.
- (
NSInteger)
clickCount;
Availability: OpenStep
Returns the click count for mouse button events.
For mouse button events, this indicates the number of
consecutive clicks: 1=single click, 2=double
click, 3=triple click, etc. The system determines
multiple clicks based on timing and proximity of
events. For non-mouse events, returns 0. Returns:
The number of consecutive clicks for this mouse event
Return the number of clicks associated with
the mouse down or up event. This method is not
applicable for any event type other than a mouse
down or mouse up.
Raises an
NSInternalInconsistencyException
if applied to any other type of event.
- (
NSGraphicsContext*)
context;
Availability: OpenStep
Returns the graphics context associated with this
event. This is the graphics context of the window
where the event occurred, which can be used for
coordinate transformations and drawing
operations. May return nil for
events not associated with a specific window.
Returns: The NSGraphicsContext associated with
this event's window
Returns the graphics
context for which this event was generated.
- (
NSInteger)
data1;
Availability: OpenStep
Returns the first custom data value for
system/application events. For
NSSystemDefined and NSApplicationDefined
events, this contains the first custom data value
set when the event was created. For other event types,
the return value is undefined. Returns: The first
custom data value for this event
Returns the
'data1' item associated with the event.
Raises NSInternalInconsistencyException if the event
is not of type NSAppKitDefined, NSSystemDefined,
NSApplicationDefined, or NSPeriodic
- (
NSInteger)
data2;
Availability: OpenStep
Returns the second custom data value for
system/application events. For
NSSystemDefined and NSApplicationDefined
events, this contains the second custom data value
set when the event was created. For other event types,
the return value is undefined. Returns: The second
custom data value for this event
Returns the
'data2' item associated with the event.
Raises NSInternalInconsistencyException if the event
is not of type NSAppKitDefined, NSSystemDefined,
NSApplicationDefined, or NSPeriodic
- (CGFloat)
deltaX;
Availability: MacOS-X 10.0.0
Returns the horizontal scroll delta for scroll
wheel events. For scroll events, this indicates the
horizontal scrolling amount. Positive values
indicate scrolling to the right, negative values
indicate scrolling to the left. The magnitude
depends on the scroll wheel resolution and system
acceleration settings. Returns: The horizontal
scroll distance for this scroll event
Returns the movement of the mouse on the X axis.
This method is only valid for NSMouseMoved,
NS*MouseDragged and NSScrollWheel events,
otherwise it will return 0.
- (CGFloat)
deltaY;
Availability: MacOS-X 10.0.0
Returns the vertical scroll delta for scroll wheel
events. For scroll events, this indicates the
vertical scrolling amount. Positive values
indicate scrolling up (away from user), negative
values indicate scrolling down (toward user). The
magnitude depends on the scroll wheel resolution
and system acceleration settings. Returns: The vertical
scroll distance for this scroll event
Returns the movement of the mouse on the Y axis.
This method is only valid for NSMouseMoved,
NS*MouseDragged and NSScrollWheel events,
otherwise it will return 0.
- (CGFloat)
deltaZ;
Availability: MacOS-X 10.0.0
Returns the z-axis scroll delta for scroll wheel
events. For scroll events with 3D scroll wheels or
trackpads, this indicates scrolling along the
z-axis (typically used for zooming). Most standard
scroll wheels return 0.0 for this value. Returns:
The z-axis scroll distance for this scroll event
Returns the movement of the mouse on the Z axis.
This method is only valid for NSMouseMoved,
NS*MouseDragged and NSScrollWheel events,
otherwise it will return 0.
The value returned is 0.0 in most cases.
- (
NSUInteger)
deviceID;
Availability: MacOS-X 10.4.0
Returns the device identifier for tablet events.
For tablet events, this uniquely identifies the input
device that generated the event. Multiple tablets
can be distinguished by their device IDs. Returns: A
unique identifier for the input device
- (
NSInteger)
eventNumber;
Availability: MacOS-X 10.0.0
Returns the unique identifier for this event. Each
event has a unique identifier that can be used to
track and correlate events. This number increases
monotonically within a session. Returns: A
unique identifier number for this event
Returns the event number associated with any mouse
event or tracking event. Event numbers are allocated
sequentially when the system creates these
events.
Raises an
NSInternalInconsistencyException
if applied to any other type of event.
- (const void*)
eventRef;
Availability: MacOS-X 10.5.0
Returns the Carbon EventRef for this event. This
provides access to the underlying Carbon event
representation, allowing integration with
Carbon event handling APIs. Returns: The Carbon
EventRef for this event, or NULL if not available
- (BOOL)
isARepeat;
Availability: OpenStep
Returns whether this is a key repeat event. For
keyboard events, this indicates whether the key
was held down long enough to trigger
key repeat. The first press returns NO,
subsequent repeat events return YES
. For non-keyboard events, the return value is undefined.
Returns: YES if this is a key repeat
event, NO if it's the initial key press
Returns a flag to say if this is a keyboard
repeat event.
Raises an
NSInternalInconsistencyException
if applied to any other type of event than an NSKeyUp or
NSKeyDown.
- (BOOL)
isEnteringProximity;
Availability: MacOS-X 10.4.0
Returns whether a tablet device is entering
proximity. For tablet proximity events, this
indicates whether the device is entering (
YES) or leaving (NO)
proximity to the tablet surface. Returns:
YES if entering proximity,
NO if leaving proximity
- (unsigned short)
keyCode;
Availability: OpenStep
Returns the hardware key code for keyboard events.
For keyboard events, this returns the raw hardware key
code that doesn't depend on the current keyboard
layout. This is useful for key bindings that should
work regardless of keyboard layout. For non-keyboard
events, the return value is undefined. Returns: The
hardware key code for this keyboard event
Returns the numeric key code of a keyboard event.
Raises an NSInternalInconsistencyException if
applied to any other type of event than an NSKeyUp
or NSKeyDown.
- (
NSPoint)
locationInWindow;
Availability: OpenStep
Returns the location of this event in the window's
coordinate system. The location is in the
window's base coordinate system (bottom-left
origin). For events not associated with a window,
the coordinates are in screen space. For non-positional
events, returns NSZeroPoint. Returns: The location
of this event in window coordinates
Returns the
window location for which this event was generated
(in the base coordinate system of the window).
- (
NSEventModifierFlags)
modifierFlags;
Availability: OpenStep
Returns the modifier flags active when this event
occurred. The modifier flags indicate which
modifier keys (Command, Option, Control, Shift,
Function, etc.) were pressed when the event
occurred. Returns: A bitmask of
NSEventModifierFlags values
Returns the modifier flag bits associated with the
event.
- (
NSEventPhase)
momentumPhase;
Availability: MacOS-X 10.7.0
Returns the momentum phase for scroll events. For
trackpad scroll events, this indicates the
momentum phase after the user has lifted their
fingers but scrolling continues due to inertia.
This helps distinguish user-driven from momentum
scrolling. Returns: The NSEventPhase value for
momentum scrolling
- (
NSEventPhase)
phase;
Availability: MacOS-X 10.7.0
Returns the gesture phase for scroll and gesture
events. For trackpad scroll and gesture events,
this indicates the phase of the gesture: began,
changed, ended, cancelled, etc. This allows
applications to properly handle multi-phase
gestures. Returns: The NSEventPhase value for
this gesture event
- (
NSUInteger)
pointingDeviceID;
Availability: MacOS-X 10.4.0
Returns the pointing device identifier for tablet
events. For tablet events, this identifies the
specific pointing device (stylus, puck, eraser,
etc.) being used with the tablet. Different tools on
the same tablet have different IDs. Returns: A unique
identifier for the pointing device
- (
NSUInteger)
pointingDeviceSerialNumber;
Availability: MacOS-X 10.4.0
Returns the serial number of the pointing device.
For tablet events, this is the hardware serial number
of the pointing device. This remains constant across
sessions and can be used to identify specific
styluses or tools. Returns: The serial number of
the pointing device
- (
NSPointingDeviceType)
pointingDeviceType;
Availability: MacOS-X 10.4.0
Returns the type of the pointing device. For tablet
events, this indicates the category of pointing
device (stylus, cursor/puck, eraser, etc.) being
used. Returns: An NSPointingDeviceType value
indicating the device type
- (float)
pressure;
Availability: OpenStep
Returns the pressure value for tablet and touch
events. For tablet events, this returns the
pressure applied to the tablet surface (0.0 = no
pressure, 1.0 = maximum pressure). For mouse
events on pressure-sensitive devices, indicates
click pressure. For other event types, returns 0.0.
Returns: The pressure value from 0.0 to 1.0
Returns the pressure associated with a mouse event.
This is a value in the range 0.0 to 1.0 and for mormal
mouse events should be set to one of those extremes.
This is used by pressure sensitive input devices.
Raises an NSInternalInconsistencyException if
applied to any other type of event than a mouse
event.
- (float)
rotation;
Availability: MacOS-X 10.4.0
Returns the rotation angle for tablet events. For
tablet events from devices that support rotation
(like art pens), this returns the rotation angle in
degrees. The angle is measured from the device's
natural orientation. Returns: The rotation angle in
degrees (0.0 to 359.9)
- (short)
subtype;
Availability: OpenStep
Returns the subtype for system and
application-defined events. For
NSSystemDefined and NSApplicationDefined
events, this provides additional categorization of
the event type. For other event types, the return value
is undefined. Returns: The event subtype identifier
Returns the 'subtype' item associated with
the event.
Raises
NSInternalInconsistencyException
if the event is not of type NSAppKitDefined,
NSSystemDefined, NSApplicationDefined,
NSPeriodic or a mouve event.
- (
NSUInteger)
systemTabletID;
Availability: MacOS-X 10.4.0
Returns the system tablet identifier. For tablet
events, this identifies the tablet system that
generated the event. This allows distinguishing
between multiple tablet systems connected to the
same computer. Returns: A unique identifier for the
tablet system
- (
NSUInteger)
tabletID;
Availability: MacOS-X 10.4.0
Returns the tablet identifier. For tablet events,
this identifies the specific tablet that generated the
event. This is useful when multiple tablets are part
of the same system. Returns: A unique identifier for the
tablet
- (float)
tangentialPressure;
Availability: MacOS-X 10.4.0
Returns the tangential pressure for tablet events.
For tablet events from devices with tangential pressure
sensors (like airbrush styluses), this returns the
side pressure value. The range is typically 0.0 to
1.0. Returns: The tangential pressure value
- (
NSPoint)
tilt;
Availability: MacOS-X 10.4.0
Returns the tilt angle for tablet events. For
tablet events from devices that support tilt
sensing, this returns the tilt of the stylus
relative to the tablet surface. The point contains
x and y tilt angles. Returns: An NSPoint with x and y
tilt angles
- (
NSTimeInterval)
timestamp;
Availability: OpenStep
Returns the timestamp when this event occurred. The
timestamp is relative to system startup time and
can be used to measure time intervals between events or
determine event ordering. Returns: The time when
this event occurred as seconds since system startup
Returns the time interval since system
startup at which this event was generated.
- (
NSInteger)
trackingNumber;
Availability: OpenStep
Returns the tracking rectangle number for tracking
events. For mouse entered/exited events generated
by tracking rectangles, this returns the tracking
rectangle number that was assigned when the
tracking rectangle was created. For other event
types, the return value is undefined. Returns: The
tracking rectangle number that generated this
event
Returns a number identifying the
tracking rectangle entered or exited.
Raises an NSInternalInconsistencyException if
applied to any other type of event than a mouse
entered or exited event.
- (
NSEventType)
type;
Availability: OpenStep
Returns the type of this event. This indicates the
fundamental category of the event (mouse,
keyboard, tracking, etc.) and determines which
other properties are meaningful. Returns: The
NSEventType value indicating this event's type
returns the type of this event.
- (unsigned long long)
uniqueID;
Availability: MacOS-X 10.4.0
Returns a unique identifier for tablet events. For
tablet events, this provides a unique identifier
that persists across the lifetime of the pointing
device session. This can be used to correlate
related tablet events. Returns: A unique identifier
for the pointing device session
- (void*)
userData;
Availability: OpenStep
Returns the user data pointer for tracking events.
For mouse entered/exited events generated by tracking
rectangles, this returns the user data pointer
that was provided when the tracking rectangle was
created. For other event types, returns NULL.
Returns: The user data pointer associated with
this tracking event
Returns usder data
associated with a tracking event... the data
assigned to the tracking rectangle concerned when
it was created..
Raises an
NSInternalInconsistencyException
if applied to any other type of event than a mouse
entered or exited event.
- (id)
vendorDefined;
Availability: MacOS-X 10.4.0
Returns vendor-defined data for tablet events. For
tablet events, this contains any additional data
defined by the tablet hardware vendor. The format
and meaning depend on the specific tablet hardware.
Returns: An object containing vendor-specific
data, or nil
- (
NSUInteger)
vendorID;
Availability: MacOS-X 10.4.0
Returns the vendor identifier for tablet events.
For tablet events, this identifies the hardware vendor
of the tablet device. This can be used to implement
vendor-specific features or workarounds.
Returns: A unique identifier for the tablet vendor
- (
NSUInteger)
vendorPointingDeviceType;
Availability: MacOS-X 10.4.0
Returns the vendor-specific pointing device type.
For tablet events, this provides additional device type
information specific to the tablet vendor. This
supplements the standard pointingDeviceType
with vendor-specific details. Returns: A
vendor-specific device type identifier
- (
NSWindow*)
window;
Availability: OpenStep
Returns the window associated with this event. This
is the window where the event occurred or the window
that should receive the event. May be nil
for global events or events that occurred outside any
window. Returns: The NSWindow associated with this
event, or nil
Returns the window
for which this event was generated.
Periodic
events have no associated window, and you should not
call this method for those events.
- (
NSInteger)
windowNumber;
Availability: OpenStep
Returns the window number associated with this
event. This is a unique identifier for the window
where the event occurred. Window numbers are assigned
by the window server and remain constant for the
lifetime of a window. Returns: The window number
for this event's associated window
Returns the
window number of the window for which this event was
generated.
Periodic events have no
associated window, and you should not call this
method for those events.
Instance Variables for NSEvent Class
@protected NSGraphicsContext*
event_context;
Availability: OpenStep
The graphics context associated with this event's
window
@protected NSTimeInterval
event_time;
Availability: OpenStep
The time when this event occurred, measured in seconds
since system startup
@protected NSEventType
event_type;
Availability: OpenStep
The type of this event (mouse, keyboard, system, etc.)
@protected NSPoint
location_point;
Availability: OpenStep
The location of the event in the window's coordinate
system
@protected NSUInteger
modifier_flags;
Availability: OpenStep
Modifier key flags active when this event occurred
@protected union _MB_event_data
union _MB_event_data;
Availability: OpenStep
Union containing event-specific data for different
event types. The appropriate struct member is
selected based on the event_type.
Mouse
event data including buttons, clicks, pressure, and
scroll deltas
Sequential event number for
this mouse event
Number of clicks for this
mouse event (1=single, 2=double, etc.)
Mouse
button number (0=left, 1=right, 2=other)
Pressure value for pressure-sensitive input
devices (0.0 to 1.0)
Horizontal scroll delta
for scroll wheel events
Vertical scroll delta
for scroll wheel events
Z-axis scroll delta for
3D scroll devices
Keyboard event data including
characters and key codes
YES
if this is a repeating key event, NO for
initial press
Characters generated by this
key event with modifiers applied
Characters that
would be generated without modifier keys
Hardware-specific key code for the
pressed key
Mouse tracking event data for
enter/exit events
Sequential event number
for this tracking event
Tracking area number
associated with this event
User-defined
data associated with the tracking area
System
and application-defined event data
Event subtype
for categorizing system/app events
First custom
data value
Second custom data value
@protected NSInteger
window_num;
Availability: OpenStep
The window number where this event occurred, or 0 if
not window-specific
Up