Hello !
It looks like there is a bug in the PhotoshopCallback mechanism.
I registered a listener for "setd" photoshop events, and the listener is triggered by a jsx script !
Jsx scripts never trigger events in Photoshop. If I setup a "normal" listener in Photoshop (using notifiers), it is not triggered.
This is a problem for me because I get notified of my own modifications, and I have no way of discriminating. That can cause infinite loops, and I can't get around it !
Are you aware of that problem ?
Below is my code for registering my listener (in my extension) :
function registerPSEvent() {
var csInterface = new CSInterface();
var event_ = new CSEvent("com.adobe.PhotoshopRegisterEvent", "APPLICATION");
event_.extensionId = csInterface.getExtensionID();
event_.appId = csInterface.getApplicationID();
event_.data = "1936028772, 1165517672, 1383294324"; //setd, Exch, Rset
csInterface.dispatchEvent(event_);
csInterface.addEventListener("PhotoshopCallback" , function(event) {
console.log("photoshop event occured : " + event.data);
});
}
And the jsx code that triggers it (a Fill Layer (Layer/New Fill Layer/Solid Color) must be active for it to work) :
#target photoshop
function setColorOfFillLayer( sColor ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID('contentLayer'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var fillDesc = new ActionDescriptor();
var colorDesc = new ActionDescriptor();
colorDesc.putDouble( charIDToTypeID('Rd '), sColor.rgb.red );
colorDesc.putDouble( charIDToTypeID('Grn '), sColor.rgb.green );
colorDesc.putDouble( charIDToTypeID('Bl '), sColor.rgb.blue );
fillDesc.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), colorDesc );
desc.putObject( charIDToTypeID('T '), stringIDToTypeID('solidColorLayer'), fillDesc );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}
var targetColor = new SolidColor();
targetColor.rgb.red = 255;
targetColor.rgb.green = 0;
targetColor.rgb.blue = 0;
setColorOfFillLayer (targetColor);