ImageGear .NET v25.1 - Updated
IPCC.Event
API Reference > ViewerControl API > IPCC.Event

Class: Event

IPCC.Event(target, type)

new Event(target, type)

Create an event object. This is the internal constructor used when the viewer emits any event. This object describes the common attributes of all events. Augmented, event-specific, values can be found in the descriptions of each event. See IPCC.EventType for specific events.
Parameters:
Name Type Description
target IPCC.ViewerControl The event target is the viewer where the event originated.
type string The name of the event type.

Members

(readonly) target :IPCC.ViewerControl

Contains the instance of the viewer that fired the event. See also IPCC.Event#getTarget. _ECMA5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8._
Type:

(readonly) type :string

Contains the type of event. See also IPCC.Event#getType. _ECMA5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8._
Type:
  • string

Methods

getTarget() → {IPCC.ViewerControl}

Gets the instance of the viewer that fired the event.
Returns:
Type
IPCC.ViewerControl
Example
var viewerObj;     
function pageCountReadyHandler (event) {
   console.log("page count ready event");
   if(event.getTarget() !== viewerObj){
       alert("The `pageCountReady` event did not originate from the expected instance of the viewer object");
   }
}
//subscribe to the pageCountReady event
viewerObj = viewer.on(IPCC.EventType.PageCountReady, pageCountReadyHandler);     

getType() → {string}

Gets the name of the event type. This will be the same value as the `eventType` argument to the IPCC.ViewerControl#on function.
See:
Returns:
a string containing event type.
Type
string
Example
function pageCountReadyHandler (event) {
   console.log("page count ready event");
   if(event.getType() !== IPCC.EventType.PageCountReady){
       alert("The event type did not match");
   }
}
//subscribe to the pageCountReady event
viewer.on(IPCC.EventType.PageCountReady, pageCountReadyHandler);

Type Definitions

eventHandler(event)

The function to call when an event occurs. When the event is triggered, all subscribed event handlers are called.
Parameters:
Name Type Description
event IPCC.Event A IPCC.Event object that represents the event. The event object is often augmented with properties which provide event specific information.
See:
Example
// Our event handler declaration.
// The handler will be called with one argument of type IPCC.Event.
function pageCountReadyEventHandler(event) {
    var target = event.getTarget(),  // `getTarget` is defined on every event object
        type = event.getType();      // `getType` is defined on every event object

    // The PageCountReady event augments the event object with property `pageCount`
    var pageCount = event.pageCount;
}

// Subscribe the event handler to an event.
viewerControl.on("PageCountReady", pageCountReadyEventHandler);