Skip to main content
Inspiring
June 14, 2016
Question

Unable to remove old CSEvent

  • June 14, 2016
  • 1 reply
  • 389 views

I have a CSEvent which I am unable to get rid - nor can I overwrite it with new data.

JS

(function(){

    'use strict';

    var csInterface = new CSInterface();

    var event = new CSEvent("com.adobe.PhotoshopRegisterEvent", "APPLICATION");

    event.extensionId = "com.example.psevents"; // Optional param

    event.data = "1936483188"; // charIDToTypeID("slct") - which is "select"

    csInterface.dispatchEvent(event);

    function init(){

    // code

    }

    // Handler for the event listener. Fires off when a layer is selected

    function PSCallback(csEvent){

        alert("callback triggered");

    }

    init();

    csInterface.addEventListener("PhotoshopCallback", PSCallback);

}());

I've tried

new CSEvent("com.adobe.PhotoshopUnRegisterEvent", "APPLICATION");
...and dispatching it, as well as using

csInterface.removeEventListener("PhotoshopCallback", PSCallback);

I am unable to remove (unregister) it completely, but once I register it again and try and add new data to this, say

event.data = "1668247673, 1885434740, 1668641824"; // copy, paste, cut

...the old event.data just comes back and the callback fires off on selections.

What's the proper way of removing old CSEvents and/or overwriting them with new data so they fire off on something else. This is getting very frustrating!

This topic has been closed for replies.

1 reply

HeimdaalAuthor
Inspiring
June 15, 2016

I did a print (alert) of the parameter sent to PSCallback:


JS

alert(JSON.stringify(csEvent, null, 4));

csEvent was populated with some old data as expected. Changing event.data here did nothing.
extensionId is "" - blank
data is "1936028772, 680"

The first digits are the stringID for the constant SET

As for the latter integer: After some scouting I found out that this is actually an ActionDescriptor ID.

csInterface.addEventListener("PhotoshopCallback", PSCallback);

Why doesn't the PSCallback need a parameter here?
Why is csEvent not declared anywhere?

Why can't I change event.data?

This is so confusing!!