PrizmDoc
Class: Event

Class: Event

PCCViewer. Event

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 PCCViewer.EventType for specific events.

Parameters:
Name Type Description
target PCCViewer.ViewerControl

The event target is the viewer where the event originated.

type string

The name of the event type.

Members

(readonly) target :PCCViewer.ViewerControl

Contains the instance of the viewer that fired the event. See also PCCViewer.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 PCCViewer.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() → {PCCViewer.ViewerControl}

Gets the instance of the viewer that fired the event.

Returns:
Type
PCCViewer.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(PCCViewer.EventType.PageCountReady, pageCountReadyHandler);     

getType() → {string}

Gets the name of the event type. This will be the same value as the eventType argument to the PCCViewer.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() !== PCCViewer.EventType.PageCountReady){
       alert("The event type did not match");
   }
}
//subscribe to the pageCountReady event
viewer.on(PCCViewer.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 PCCViewer.Event

A PCCViewer.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 PCCViewer.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);

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback