3 Replies Latest reply on Jan 21, 2011 1:11 PM by Michael L Hale

    Is it possible to know which tool is selected

    pixelG

      I've successfully registered for the 'slct' event and have Photoshop calling back to my script so that I can handle it. However, I'm trying to target the marquee select tool specifically and so I need to know which tool has been selected. Is there any way to find that out?

       

      Thanks for your help!

      Jeremy

        • 1. Re: Is it possible to know which tool is selected
          pixelG Level 1

          I probably need to provide better context for my question. I apologize for not doing so beforehand; it was late at night by the time I decided to finally ask the experts here (after hours of unsuccessfully attempting to figure this out on my own). So here it is (let me know if you need more information):

           

          tools.png

          First, pictured at left are the Photoshop tools to which I am referring. When a user selects a tool from the tool palette, I am able to get the message. But what I don't know is how to determine which tool has been selected so that I can accurately reflect the state of the marquee tool in my panel UI. Here is a snippet of the handling code in AS3:

           

          private const SLCT_INT:int = Photoshop.app.charIDToTypeID('slct');

           

           

          private function myPhotoshopCallback(eventID:Number, descID:Number):void {

           

          var desc:ActionDescriptor = new ActionDescriptor();

          desc.fromID(descID);

           

          switch (eventID)

          {

           

           

          case SLCT_INT:

          //handle slct case

          //check if marquee is selected and if so select the panel's marquee button, else deselect the panel's marquee button

           

          jsxInterface.popAlert(

          "slct");

           

          break;

           

          default:

           

          //should not get here

           

          break;

          }

          }

          I know I have everything hooked up correctly because I am calling a JSX function to show an alert and that is showing up correctly:

           

          //JSX function call from AS

          function popAlert(s) {
              alert(s);
              }

           

          alert.png

           

          While debugging, I see that the eventID = 1936483188:

          eventID.png

           

           

          So... is there any way to further disambiguate which tool is triggering the event?

           

          Thank you in advance for any help you can provide. I'll keep digging into this, but I hope someone with more expertise than I can chime in as I am stumped at present.

           

          Jeremy

          • 2. Re: Is it possible to know which tool is selected
            pixelG Level 1

            It seems possible to do this since I see that Configurator 2.0 has this kind of functionality... anyone have any thoughts on how to do this in a custom panel?

            • 3. Re: Is it possible to know which tool is selected
              Michael L Hale Level 5

              Sorry for posting this so late and an Extendscript example but perhaps you have not found an answer and can port over to actionscript.

               

              To find what was selected in the select event you search the descriptor.

               

                    var ref = desc.getReference(app.charIDToTypeID('null'));// get the reference from the descriptor
                    var cls = ref.getDesiredClass();// get the class from the reference
                    var selected = app.typeIDToStringID(cls);// if the Rectangular Marquee Tool was selected this = 'marqueeRectTool'