Page 1 of 1

Restart/reload extension when new document is created or opened

Posted: Thu Dec 22, 2016 3:36 pm
by ApWizard
Hi!
I was thinking: "how to reload/restart a persistent extension when a new document is created or one is opened?"

I think I've to use

Code: Select all


app.notifier.add("Opn ", <something here>)
inside the JSX file but I'm not able to come up with something useful.

Some doubts:
  • • the example above takles the opening of a document but not the creation of a new one;
    • how do I effectively reload/restart the extension?
Thank you in advance :)

Re: Restart/reload extension when new document is created or opened

Posted: Mon Jan 02, 2017 9:34 am
by JavierAroche
You should take a look at this photoshop-dom-event npm module by Antonio. It lets you listen to an event and run a callback function when that event is triggered. He even has a CEP panel example.
https://github.com/antonio-gomez/photoshop-dom-event
• the example above takles the opening of a document but not the creation of a new one;
The event triggered when making a new document is "Mk ". But it is also the same for making new layers. So you'll have to read the contents of the received data to determine if the user made a new document.
• how do I effectively reload/restart the extension?
You can refresh the panel like you would refresh a browser. It's not ideal, since you'll see a flash when reloading, but it's a decent solution.

Code: Select all

window.location.reload();