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

Methods

Properties

  •   type

    A string that identifies the event.

    property
  •   bubbles

    Indicates if event will bubble.

    property
  •   target

    The object that dispatched the event.

    property
  •   currentTarget

    The object the event is currently bubbling at.

    property

Properties

bubbles

Indicates if event will bubble.

@property (nonatomic, readonly) BOOL bubbles

Discussion

Indicates if event will bubble.

Declared In

SPEvent.h

currentTarget

The object the event is currently bubbling at.

@property (weak, nonatomic, readonly) SPEventDispatcher *currentTarget

Discussion

The object the event is currently bubbling at.

Declared In

SPEvent.h

target

The object that dispatched the event.

@property (weak, nonatomic, readonly) SPEventDispatcher *target

Discussion

The object that dispatched the event.

Declared In

SPEvent.h

type

A string that identifies the event.

@property (nonatomic, readonly) NSString *type

Discussion

A string that identifies the event.

Declared In

SPEvent.h

Class Methods

eventWithType:

Factory method.

+ (instancetype)eventWithType:(NSString *)type

Discussion

Factory method.

Declared In

SPEvent.h

eventWithType:bubbles:

Factory method.

+ (instancetype)eventWithType:(NSString *)type bubbles:(BOOL)bubbles

Discussion

Factory method.

Declared In

SPEvent.h

Instance Methods

initWithType:

Initializes a non-bubbling event.

- (instancetype)initWithType:(NSString *)type

Discussion

Initializes a non-bubbling event.

Declared In

SPEvent.h

initWithType:bubbles:

Initializes an event object that can be passed to listeners. Designated Initializer.

- (instancetype)initWithType:(NSString *)type bubbles:(BOOL)bubbles

Discussion

Initializes an event object that can be passed to listeners. Designated Initializer.

Declared In

SPEvent.h

stopImmediatePropagation

Prevents any other listeners from receiving the event.

- (void)stopImmediatePropagation

Discussion

Prevents any other listeners from receiving the event.

Declared In

SPEvent.h

stopPropagation

Prevents listeners at the next bubble stage from receiving the event.

- (void)stopPropagation

Discussion

Prevents listeners at the next bubble stage from receiving the event.

Declared In

SPEvent.h