HTML Panels Tips: #12 CEP Application Events

Davide Barranca —  — 4 Comments

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.

  • ""
  • ""
  • "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).


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 "" event, which would be of great use.

Print Friendly, PDF & Email

4 responses to HTML Panels Tips: #12 CEP Application Events

  1. Hey! I was passed your details from Uwe on the Adobe Forums. I need to find a way to post results entered in the HTML Extension, and use within different scripts.
    I am using the HTML Panel at the moment to trigger compiled scripts, and all the inputting is done by the use in ScriptUI dialogs that I have written.
    This post (with my limited knowledge) is either too deep for me, or working the other way around to the way i am needing.
    Here is a copy of my original post…
    I am not sure if I should be posting this topic in this forum, so if anyone wants to suggest an alternative please say!
    While I am here, I am starting to make some very basic HTML Extensions using Eclipse with the Adobe Extension Builder 3.
    I can build an interface to trigger off static scripts, which works well, and within the scripts runtime the user interacts, adds data/variables etc using scriptUI.
    What I would like to do is collect the users input at Panel level within a form field in the HTML, but, I cant see a way for me to write data to “somewhere” and then request access to the inputted data while running my script.
    I dont know if the HTML can write to a text file stored on my disk, but I have always thought for security reasons this is forbidden in simple HTML. Maybe writing to the Applications label property, but I dont know how, or if this bridge can be coded.
    Are there other ways that can do this without too much complications?

    Thanks as always,

    If you could spare a few minutes and give me your thoughts that would be cool!



    • Hi Roy,
      can’t you just pass the needed info to JSX functions as parameters? Like JS calls JSX1 passing {data}, then JSX1 passes {data} along to JSX2 if needed, etc.
      Otherwise – if the amount of data is really big (so much that it would slow down everything – but I guess it has to be really B-I-G for that) you can always write JSON to disk somewhere and import them back into JSX (loading the appropriate JSON library, because ExtendScript can’t deal with JSON natively).
      Hope this helps!

  2. Hello Davide,

    Do you have some clues on how to manage drag/drop events from an HTML5 panel to the Application ? f.e dropping an image url from a panel to the App workspace & then launch a callback and process this image as a new document…

    Best Regards,

  3. Regarding “” event. This event is dispatched to the native APIs (C++ APIs), basically the closing HTML extension cannot listen to this event.

Leave a Reply

Text formatting is available via select .

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">