Listen to "document change" events in XD panels?

Is there a robust way to listen to “document change” events (focus/blur)?
I need to know which document/window is in front (if there are multiple documents open)…
application.activeDocument is not providing this…

As far as I know this is not possible yet. Just want to make sure I didn’t miss anything here :wink:


There is only one active document per plugin instantiation–i.e., a plugin is started up for each document, so there’s always just the one, and it’s always active.

You get document change notices via your panel’s update callback.

Thanks Chris for the reply. That’s true. Each document (XD window) gets its own panel instance. But I can have multiple windows/documents open at a time, right? I need to know which window/document is in front or has the focus… or simply which document the user was touching last.

Consider this a feature request for something like:

XD_window.addEventListener(‘blur/focus’, …);






Sent with Shift

There is no specific event for simply switching between multiple document windows. The closest thing is update(), which fires whenever the user changes the selection or any document content.

Each document window is running an independent instance of each plugin. If you would like multiple instances of a plugin to communicate/coordinate with each other, then one idea is to write data, such as the last touched document’s title or GUID, to the plugin’s data or temporary folder:

Thanks David. That is exactly what I did so far: using the update event. But it is not the most elegant way. It will be fired way too often. That is why I was looking for a more effective solution…

In the future it would be nice to have the main window propagate a blur/focus event to the plugin context…

Sent with Shift

What’s the use case? Curious.

I have to connect to an external app that should always show which document the user currently has selected or is in front and has focus…

Sent with Shift