Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

How should I handle multiple event listeners in my HTML5 extension?

$
0
0

Hi all,

 

I want to listen for make ("Mk  ") events and duplicate ("Dplc") events, each using a different handler. Currently both event handlers are triggered when either event is received.

The relevant javascript code is:

 

var make_e = new CSEvent(  'com.adobe.PhotoshopRegisterEvent',  'APPLICATION',  csInterface.getApplicationID(),  csInterface.getExtensionID()
);
make_e.data = 1298866208; // stringIDToTypeID('make')
csInterface.dispatchEvent(make_e);
csInterface.addEventListener( 'PhotoshopCallback', make_callback );

var dplc_e = new CSEvent(
  'com.adobe.PhotoshopRegisterEvent',  'APPLICATION',  csInterface.getApplicationID(),  csInterface.getExtensionID()
);
dplc_e.data = 1148218467; // stringIDToTypeID('duplicate')
csInterface.dispatchEvent(dplc_e);
csInterface.addEventListener( 'PhotoshopCallback', dplc_callback );


function make_callback(e){ console.log('make'); }
function make_callback(e){ console.log('duplicate'); }

 

When either event is received the console logs the output of both handlers. In the below example I first created a new layer then duplicated a layer.

 

make c_LayerPanelSection.js:90

duplicate c_LayerPanelSection.js:94

make c_LayerPanelSection.js:90

duplicate c_LayerPanelSection.js:94


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>