SPEvent Class Reference
| Inherits from | NSObject |
| Declared in | SPEvent.h |
Overview
The SPEvent class contains data that describes an event.
SPEventDispatchers create instances of this class and send them to registered listeners. An event
contains information that characterizes an event, most importantly the event type and if the event
bubbles. The target of an event is the object that dispatched it.
For some event types, this information is sufficient; other events may need additional information to be carried to the listener. In that case, you can subclass SPEvent and add properties with all the information you require. The SPEnterFrameEvent is an example for this practice; it adds a property about the time that has passed since the last frame.
Furthermore, the event class contains methods that can stop the event from being processed by other listeners - either completely or at the next bubble stage.
Tasks
Initialization
-
– initWithType:bubbles:Initializes an event object that can be passed to listeners. Designated Initializer.
-
– initWithType:Initializes a non-bubbling event.
-
+ eventWithType:bubbles:Factory method.
-
+ eventWithType:Factory method.
Methods
-
– stopImmediatePropagationPrevents any other listeners from receiving the event.
-
– stopPropagationPrevents listeners at the next bubble stage from receiving the event.
Properties
-
typeA string that identifies the event.
property -
bubblesIndicates if event will bubble.
property -
targetThe object that dispatched the event.
property -
currentTargetThe object the event is currently bubbling at.
property
Properties
bubbles
Indicates if event will bubble.
@property (nonatomic, readonly) BOOL bubblesDiscussion
Indicates if event will bubble.
Declared In
SPEvent.hcurrentTarget
The object the event is currently bubbling at.
@property (weak, nonatomic, readonly) SPEventDispatcher *currentTargetDiscussion
The object the event is currently bubbling at.
Declared In
SPEvent.hClass Methods
Instance Methods
initWithType:
Initializes a non-bubbling event.
- (instancetype)initWithType:(NSString *)typeDiscussion
Initializes a non-bubbling event.
Declared In
SPEvent.hinitWithType:bubbles:
Initializes an event object that can be passed to listeners. Designated Initializer.
- (instancetype)initWithType:(NSString *)type bubbles:(BOOL)bubblesDiscussion
Initializes an event object that can be passed to listeners. Designated Initializer.
Declared In
SPEvent.h