Class CKEDITOR.event
This is a base class for classes and objects that require event
handling features.
Do not confuse this class with CKEDITOR.dom.event which is
instead used for DOM events. The CKEDITOR.event class implements the
internal event system used by the CKEditor to fire API related events.
Defined in: core/event.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Creates an event class instance.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
CKEDITOR.event.implementOn(targetObject)
Implements the CKEDITOR.event features in an object.
|
fire(eventName, data, editor)
Fires an specific event in the object.
|
|
fireOnce(eventName, data, editor)
Fires an specific event in the object, releasing all listeners
registered to that event.
|
|
hasListeners(eventName)
Checks if there is any listener registered to a given event.
|
|
on(eventName, listenerFunction, scopeObj, listenerData, priority)
Registers a listener to a specific event in the current object.
|
|
removeListener(eventName, listenerFunction)
Unregisters a listener function from being called at the specified
event.
|
Class Detail
CKEDITOR.event()
Since:
3.0
Creates an event class instance. This constructor is rearely used, being
the #.implementOn function used in class prototypes directly
instead.
Method Detail
<static>
{Undefined}
CKEDITOR.event.implementOn(targetObject)
Since:
3.0
Implements the CKEDITOR.event features in an object.
var myObject = { message : 'Example' }; CKEDITOR.event.implementOn( myObject }; myObject.on( 'testEvent', function() { alert( this.message ); // "Example" }); myObject.fire( 'testEvent' );
- Parameters:
- {Object} targetObject
- The object into which implement the features.
{Boolean|Object}
fire(eventName, data, editor)
Since:
3.0
Fires an specific event in the object. All registered listeners are
called at this point.
someObject.on( 'someEvent', function() { ... } ); someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // both listeners are called
someObject.on( 'someEvent', function( event ) { alert( event.data ); // "Example" }); someObject.fire( 'someEvent', 'Example' );
- Parameters:
- {String} eventName
- The event name to fire.
- {Object} data Optional
- Data to be sent as the CKEDITOR.eventInfo#data when calling the listeners.
- {CKEDITOR.editor} editor Optional
- The editor instance to send as the CKEDITOR.eventInfo#editor when calling the listener.
- Returns:
- {Boolean|Object} A booloan indicating that the event is to be canceled, or data returned by one of the listeners.
{Boolean|Object}
fireOnce(eventName, data, editor)
Since:
3.0
Fires an specific event in the object, releasing all listeners
registered to that event. The same listeners are not called again on
successive calls of it or of #fire.
someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // above listener called someObject.fireOnce( 'someEvent' ); // above listener called someObject.fire( 'someEvent' ); // no listeners called
- Parameters:
- {String} eventName
- The event name to fire.
- {Object} data Optional
- Data to be sent as the CKEDITOR.eventInfo#data when calling the listeners.
- {CKEDITOR.editor} editor Optional
- The editor instance to send as the CKEDITOR.eventInfo#editor when calling the listener.
- Returns:
- {Boolean|Object} A booloan indicating that the event is to be canceled, or data returned by one of the listeners.
{Undefined}
hasListeners(eventName)
Since:
3.0
Checks if there is any listener registered to a given event.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); alert( someObject.hasListeners( 'someEvent' ) ); // "true" alert( someObject.hasListeners( 'noEvent' ) ); // "false"
- Parameters:
- {String} eventName
- The event name.
{Undefined}
on(eventName, listenerFunction, scopeObj, listenerData, priority)
Since:
3.0
Registers a listener to a specific event in the current object.
someObject.on( 'someEvent', function() { alert( this == someObject ); // "true" });
someObject.on( 'someEvent', function() { alert( this == anotherObject ); // "true" } , anotherObject );
someObject.on( 'someEvent', function( event ) { alert( event.listenerData ); // "Example" } , null, 'Example' );
someObject.on( 'someEvent', function() { ... } ); // 2nd called someObject.on( 'someEvent', function() { ... }, null, null, 100 ); // 3rd called someObject.on( 'someEvent', function() { ... }, null, null, 1 ); // 1st called
- Parameters:
- {String} eventName
- The event name to which listen.
- {Function} listenerFunction
- The function listening to the event. A single CKEDITOR.eventInfo object instanced is passed to this function containing all the event data.
- {Object} scopeObj Optional
- The object used to scope the listener call (the this object. If omitted, the current object is used.
- {Object} listenerData Optional
- Data to be sent as the CKEDITOR.eventInfo#listenerData when calling the listener.
- {Number} priority Optional
- The listener priority. Lower priority listeners are called first. Listeners with the same priority value are called in registration order. Defaults to 10.
{Undefined}
removeListener(eventName, listenerFunction)
Since:
3.0
Unregisters a listener function from being called at the specified
event. No errors are thrown if the listener has not been
registered previously.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener called someObject.removeListener( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener not called
- Parameters:
- {String} eventName
- The event name.
- {Function} listenerFunction
- The listener function to unregister.