How should I handle multiple event listeners in my HTML5 extension?
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.
