HTML Panels can listen to CEP Application Events - that is to say, Events dispatched by the Host (Photoshop, InDesign…) when something related to the app itself, or its documents, happens.
List of Photoshop Events
To date (CC 2014, version 2014.0.0 Release, 20140508.r58) this is the list of the Events that Photoshop is able to dispatch. Hopefully the names are self-explanatory.
"com.adobe.csxs.events.AppOffline"
"com.adobe.csxs.events.AppOnline"
"applicationActivate"
"applicationBeforeQuit"
"documentAfterActivate"
"documentAfterDeactivate"
"documentEdited"
Mind you, according to the Extension SDK guide some of them aren’t supported in Photoshop yet; others aren’t listed there (but they come from the CEP HTML Test Panel from the Samples GitHub repo).
Implementation
As easy as it gets - this goes in the JS:
Event Parameters
The event object passed to the callback in Photoshop has several properties:
appId: "PHSX"
extensionId: ""
scope: "APPLICATION"
type
data
According to each type
, the data
 might come as an XML String, as follows:
Mind you, I’ve been able to log the applicationBeforeQuit
event only trying to quit Photoshop when an unsaved document was open - this gives the time for the console.dir
to be logged, otherwise the Object is empty, after the app has quit. Also, I haven’t been able to successfully intercept the "com.adobe.csxs.events.ExtensionUnloaded"
 event, which would be of great use.
The Photoshop HTML Panels Development Course
If you’re reading here, you might be interested in my Photoshop Panels development – so let me inform you that I’ve authored a full course:
- 300 pages PDF
- 3 hours of HD screencasts
- 28 custom Panels with commented code
Check it out! Please help me spread the news – I’ll be able to keep producing more exclusive content on this blog. Thank you!