# CKEditor 3.0 JavaScript API Documentation

Code Index | File Index

## Namespaces

- CKEDITOR
- CKEDITOR.ajax
- CKEDITOR.config
- CKEDITOR.dom
- CKEDITOR.dtd
- CKEDITOR.env
- CKEDITOR.imageCacher
- CKEDITOR.loader
- CKEDITOR.plugins
- CKEDITOR.resourceManager
- CKEDITOR.scriptLoader
- CKEDITOR.skins
- CKEDITOR.test
- CKEDITOR.themes
- CKEDITOR.tools

## Classes

- CKEDITOR.commandDefinition
- CKEDITOR.dialog
- CKEDITOR.dialog.buttonDefinition
- CKEDITOR.dialog.contentDefinition
- CKEDITOR.dialog.contentDefinitionObject
- CKEDITOR.dialog.dialogDefinition
- CKEDITOR.dialog.dialogDefinitionObject
- CKEDITOR.dialog.uiElementDefinition
- CKEDITOR.dialogCommand
- CKEDITOR.dom.document
- CKEDITOR.dom.domObject
- CKEDITOR.dom.element
- CKEDITOR.dom.event
- CKEDITOR.dom.node
- CKEDITOR.dom.selection
- CKEDITOR.dom.text
- CKEDITOR.dom.window
- CKEDITOR.editor
- CKEDITOR.event
- CKEDITOR.eventInfo
- CKEDITOR.focusManager
- CKEDITOR.htmlParser
- CKEDITOR.htmlParser.cdata
- CKEDITOR.htmlParser.comment
- CKEDITOR.htmlParser.element
- CKEDITOR.htmlParser.fragment
- CKEDITOR.htmlParser.text
- CKEDITOR.htmlWriter
- CKEDITOR.keystrokeHandler
- CKEDITOR.pluginDefinition
- CKEDITOR.ui
- CKEDITOR.ui.button
- CKEDITOR.ui.dialog.button
- CKEDITOR.ui.dialog.checkbox
- CKEDITOR.ui.dialog.file
- CKEDITOR.ui.dialog.fileButton
- CKEDITOR.ui.dialog.hbox
- CKEDITOR.ui.dialog.html
- CKEDITOR.ui.dialog.labeledElement
- CKEDITOR.ui.dialog.radio
- CKEDITOR.ui.dialog.select
- CKEDITOR.ui.dialog.textarea
- CKEDITOR.ui.dialog.textInput
- CKEDITOR.ui.dialog.uiElement
- CKEDITOR.ui.dialog.vbox
- CKEDITOR.ui.handlerDefinition
- CKEDITOR.xml

# Class CKEDITOR.event

Defined in: core/event.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| CKEDITOR.event() This is a base class for classes and objects that require event handling features.

Method Summary
Method Attributes | Method Name and Description
--- | ---
<static> | CKEDITOR.event.implementOn(targetObject, isTargetPrototype) 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
This is a base class for classes and objects that require event handling features.
Method Detail
<static> {Undefined} CKEDITOR.event.implementOn(targetObject, isTargetPrototype)
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 in which implement the features.
{Undefined} isTargetPrototype

{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.
{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.

Copyright © 2003-2009, CKSource - Frederico Knabben. All rights reserved.