• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dispatching an Event from index.jsx to the index.js

Explorer ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

I'm trying to build some kind of export tool in photoshop and i'm struggaling a bit. I'm trying to find the answer but i can't seem to find it. Is it possible to dispatch an event from the index.jsx(host) file and listen to it inside the index.js(client)?

I've found this but i need it the other way around.

 
Folder structure looks like this.

Schermafbeelding 2020-09-15 om 20.16.37.png


TOPICS
Actions and scripting

Views

442

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 15, 2020 Sep 15, 2020

You could raise a CSXS event for this on the jsx end and then add eventhandler for this on the js end. Something like the following

 

//on the jsx end
var xLib = new ExternalObject("lib:\PlugPlugExternalObject");
if (xLib)
{
  var eventObj = new CSXSEvent();
  eventObj.type = "com.custom.event";
  eventObj.data = "hello"
  eventObj.dispatch();
}
//On the js end
var csInterface = new CSInterface();
csInterface.addEventListener("com.custom.event", function(event)
{
  alert(event.data)
});

 

-Mana

...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

You could raise a CSXS event for this on the jsx end and then add eventhandler for this on the js end. Something like the following

 

//on the jsx end
var xLib = new ExternalObject("lib:\PlugPlugExternalObject");
if (xLib)
{
  var eventObj = new CSXSEvent();
  eventObj.type = "com.custom.event";
  eventObj.data = "hello"
  eventObj.dispatch();
}
//On the js end
var csInterface = new CSInterface();
csInterface.addEventListener("com.custom.event", function(event)
{
  alert(event.data)
});

 

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Hi Manan,

Thanks! This is exactly what i need!!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 13, 2020 Dec 13, 2020

Copy link to clipboard

Copied

I want to receive data back from CSXSEvent in MacOS. Are you have solution?

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 14, 2020 Dec 14, 2020

Copy link to clipboard

Copied

Hi @AnonID,

Events are one-way means of communication. If you need to send data from jsx to js then you can use the code snippet I wrote above. If you need to send data from js to jsx then you can do that directly by calling a method. Can you specify what exactly you are trying to do?

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 14, 2020 Dec 14, 2020

Copy link to clipboard

Copied

LATEST

I want to send data from jsx to js, and return data back from js to jsx in this function. In Mac, code in jsx execute done before code in dispatch event execute. Are you have solution for that? Can you check inbox of me?

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines