Class CPEvent

CPObject
    extended byCPEvent

@implementation CPEvent : CPObject

CPEvent encapsulates the details of a Cappuccino keyboard or mouse event.


Method Summary
+(CPEvent)keyEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned int)modifierFlags timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)repeatKey keyCode:(unsigned short)code
          Creates a new keyboard event.
+(id)mouseEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned)modifierFlags timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext eventNumber:(int)anEventNumber clickCount:(int)aClickCount pressure:(float)aPressure
          Creates a new mouse event.
+(CPEvent)otherEventWithType:(CPEventType)anEventType location:(CGPoint)aLocation modifierFlags:(unsigned)modifierFlags timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext subtype:(short)aSubtype data1:(int)aData1 data2:(int)aData2
          Creates a new custom event.
+(void)startPeriodicEventsAfterDelay:(CPTimeInterval)aDelay withPeriod:(CPTimeInterval)aPeriod
          Generates periodic events every aPeriod seconds.
+(void)stopPeriodicEvents
          Stops the periodic events from being generated.
-(int)buttonNumber
          Returns the button number for the mouse that generated the event.
-(CPString)characters
          Returns the characters associated with this event (keyboard only).
-(CPString)charactersIgnoringModifiers
          Returns the character ignoring any modifiers (except shift).
-(int)clickCount
          Returns the number of clicks that caused this event.
-(float)deltaX
          Returns the change in the x-axis for a mouse event.
-(float)deltaY
          Returns the change in the y-axis for a mouse event.
-(float)deltaZ
          Returns the change in the x-axis for a mouse event.
-(BOOL)isARepeat
          Returns YES if the keyboard event was caused by the key being held down.
-(unsigned short)keyCode
          Returns the key's key code.
-(CGPoint)locationInWindow
          Returns the location of the mouse (for mouse events).
-(unsigned)modifierFlags
          Returns event information as a bit mask.
-(float)pressure
-(CPTimeInterval)timestamp
          Returns the time the event occurred.
-(CPEventType)type
          Returns the type of event.
-(CPWindow)window
          Returns the event's associated window.
-(int)windowNumber
          The number of the window associated with the event.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass


Method Detail

keyEventWithType

+(CPEvent)keyEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned int)modifierFlags timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)repeatKey keyCode:(unsigned short)code
Creates a new keyboard event.
Parameters:
anEventType - the event type. Must be one of CPKeyDown, CPKeyUp or CPFlagsChanged
aPoint - the location of the cursor in the window specified by aWindowNumber
modifierFlags - a bitwise combination of the modifiers specified in the CPEvent globals
aTimestamp - the time the event occurred
aWindowNumber - the number of the CPWindow where the event occurred
aGraphicsContext - the graphics context where the event occurred
characters - the characters associated with the event
unmodCharacters - the string of keys pressed without the presence of any modifiers other than Shift
repeatKey - YES if this is caused by the system repeat as opposed to the user pressing the key again
code - a number associated with the keyboard key of this event
Throws:
CPInternalInconsistencyException - if anEventType is not a CPKeyDown, CPKeyUp or CPFlagsChanged
Returns:
the keyboard event

mouseEventWithType

+(id)mouseEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned)modifierFlags timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext eventNumber:(int)anEventNumber clickCount:(int)aClickCount pressure:(float)aPressure
Creates a new mouse event
Parameters:
anEventType - the event type
aPoint - the location of the cursor in the window specified by aWindowNumber
modifierFlags - a bitwise combination of the modifiers specified in the CPEvent globals
aTimestamp - the time the event occurred
aWindowNumber - the number of the CPWindow where the event occurred
aGraphicsContext - the graphics context where the event occurred
anEventNumber - a number for this event
aClickCount - the number of clicks that caused this event
aPressure - the amount of pressure applied to the input device (ranges from 0.0 to 1.0)
Throws:
CPInternalInconsistencyException - if an invalid event type is provided
Returns:
the new mouse event

otherEventWithType

+(CPEvent)otherEventWithType:(CPEventType)anEventType location:(CGPoint)aLocation modifierFlags:(unsigned)modifierFlags timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext subtype:(short)aSubtype data1:(int)aData1 data2:(int)aData2
Creates a new custom event
Parameters:
anEventType - the event type. Must be one of CPAppKitDefined, CPSystemDefined, CPApplicationDefined or CPPeriodic
aLocation - the location of the cursor in the window specified by aWindowNumber
modifierFlags - a bitwise combination of the modifiers specified in the CPEvent globals
aTimestamp - the time the event occurred
aWindowNumber - the number of the CPWindow where the event occurred
aGraphicsContext - the graphics context where the event occurred
aSubtype - a numeric identifier to differentiate this event from other custom events
aData1 - more data that describes the event
aData2 - even more data that describes the event
Throws:
CPInternalInconsistencyException - if an invalid event type is provided
Returns:
the new custom event

startPeriodicEventsAfterDelay

+(void)startPeriodicEventsAfterDelay:(CPTimeInterval)aDelay withPeriod:(CPTimeInterval)aPeriod
Generates periodic events every aPeriod seconds.
Parameters:
aDelay - the number of seconds before the first event
aPeriod - the length of time in seconds between successive events

stopPeriodicEvents

+(void)stopPeriodicEvents
Stops the periodic events from being generated

buttonNumber

-(int)buttonNumber
Returns the button number for the mouse that generated the event.

characters

-(CPString)characters
Returns the characters associated with this event (keyboard only)
Throws:
CPInternalInconsistencyException - if this method is called on a non-key event

charactersIgnoringModifiers

-(CPString)charactersIgnoringModifiers
Returns the character ignoring any modifiers (except shift).
Throws:
CPInternalInconsistencyException - if this method is called on a non-key event

clickCount

-(int)clickCount
Returns the number of clicks that caused this event. (mouse only)

deltaX

-(float)deltaX
Returns the change in the x-axis for a mouse event.

deltaY

-(float)deltaY
Returns the change in the y-axis for a mouse event.

deltaZ

-(float)deltaZ
Returns the change in the x-axis for a mouse event.

isARepeat

-(BOOL)isARepeat
Returns YES if the keyboard event was caused by the key being held down.
Throws:
CPInternalInconsistencyException - if this method is called on a non-key event

keyCode

-(unsigned short)keyCode
Returns the key's key code.
Throws:
CPInternalInconsistencyException - if this method is called on a non-key event

locationInWindow

-(CGPoint)locationInWindow
Returns the location of the mouse (for mouse events). If this is not a mouse event, it returns nil. If window returns nil, then the mouse coordinates will be based on the screen coordinates. Otherwise, the coordinates are relative to the window's coordinates.
Returns:
the location of the mouse, or nil for non-mouse events.

modifierFlags

-(unsigned)modifierFlags
Returns event information as a bit mask

pressure

-(float)pressure

timestamp

-(CPTimeInterval)timestamp
Returns the time the event occurred

type

-(CPEventType)type
Returns the type of event.

window

-(CPWindow)window
Returns the event's associated window

windowNumber

-(int)windowNumber
The number of the window associated with the event.

Created on Sat Sep 13 14:15:43 PDT 2008