Class: Events

Cadcorp.Util.Events

new Events(config)

An events object that handles custom events
Parameters:
Name Type Description
config Cadcorp.Util.EventConfig Configuration for this event object

Members

parentObject

Properties:
Name Type Description
parentObject object The owner object for this event object

Methods

destroy()

Destroys this event object.

getIndex(type, context, handler) → {number}

Gets the index of this event handler
Parameters:
Name Type Description
type string The event type
context Object The context the event handler will be called in
handler function The function that will be called when the event is triggered
Returns:
The index of the event handler
Type
number

isRegistered(type, context, handler) → {boolean}

Is this event handler registered with this event object
Parameters:
Name Type Description
type string The event type
context Object The context the event handler will be called in
handler function The function that will be called when the event is triggered
Returns:
true if the event handler has been registered, otherwise false
Type
boolean

register(type, contextnullable, handler)

Register an event on the events object. When the event is triggered, the 'handler' function will be called, in the context of 'context'.
Parameters:
Name Type Attributes Description
type string The event type
context Object <nullable>
The context the event handler will be called in. If no object is specified, default is the Events's 'parentObject' property.
handler function The function that will be called when the event is triggered

trigger(type, eventDatanullable)

Trigger a specified registered event.
If eventData is supplied, type and object properties will be added.
If eventData is null a new object is created with type and object properties.
In either case eventData will be passed to all listeners
Parameters:
Name Type Attributes Description
type string The event type
eventData Object <nullable>
An object containing event data, will be passed to the listener.

unregister(type, contextnullable, handler)

UnRegister an event on the events object. To unregister an event the type, context and handler must the the same as when register was called
Parameters:
Name Type Attributes Description
type string The event type
context Object <nullable>
The context the event handler will be called in
handler function The function that will be called when the event is triggered