0

Is it possible to add event listeners to a viewing application?

I know it's possible to add them on a viewer object using the addEventListener method, but how can I add events to a viewing application?

CLARIFICATION: I know I can use this.viewerApp.getCurrentViewer() to get the viewer and then use addEventListener, but is there a better or more correct way?

Ivan Aguilar
  • 565
  • 1
  • 7
  • 22
  • Could you share the use case why you want to add event listeners to `ViewerApplication` rather than `Viewer3D`? `ViewerApplication` is just a utility class for creating a viewer instance as I know. – Eason Kang Dec 20 '17 at 16:16
  • @EasonKang I was just wondering if I could add them to the `ViewingApplication`, but from your response and @Philippe's answer I see I can't. – Ivan Aguilar Dec 21 '17 at 07:30

1 Answers1

1

You cannot, ViewingApplication is just a wrapper around the Viewer object, so you need to add the event to viewer itself:

function onItemLoadSuccess(viewer, item) {
    viewer.addEventListener (...)
}

// or
var viewer = viewerApp.getCurrentViewer() //only after onItemLoadSuccess, viewer is not instanciated before
viewer.addEventListener (...)
Felipe
  • 4,325
  • 1
  • 14
  • 19