Photoshop: Event listener for layer selections


I read Davide’s intro to Photoshop event listeners using the CSEvent class:

And long story short: I got things working but I can’t seem to make an event trigger on a layer selection.
Using the charID “slct” makes the event fire when using any of the selection tools (polygon lasso, magic wand, etc) but not when selecting layers.

I found some related threads on the Adobe boards:

…but in neither case are they working with CSEvent.
If I understand this correctly, I need to provide additional parameters to my before dispatching the event with csInterface.dispatchEvent(event) - but how? I don’t understand the syntax fully, and the documentation isn’t all that good.


    'use strict';  
    var csInterface = new CSInterface();  
    var event = new CSEvent("com.adobe.PhotoshopRegisterEvent", "APPLICATION");  
    event.extensionId = "com.example.psevents"; = "1936483188"; // charIDToTypeID("slct") - which is "select"  
    function init(){  
        // code  
    function PSCallback(csEvent){  
        alert("it works!");  
    csInterface.addEventListener("PhotoshopCallback", PSCallback);  

The callback here is fired off on selections, but not the ones of the type I want! It works on selections done with the marquee tool, polygon lasso, etc - and when selecting color swatches in the swatches panel. But it doesn’t fire off on layer selections (which is the one and only event I want really).

Has anyone worked with this before and is able to provide some insights? Thanks.