1 Reply Latest reply: Jan 31, 2014 1:08 PM by kamih RSS

    How to query active tool?

    kamih Community Member

      Hello!

       

      I am writing a Photoshop plugin that needs to disable itself when certain tools are active.

      I have added a callback for the select event, based on the Listener example, and am mostly happy with the results.

      Here is my callback function:

      http://pastebin.com/dWGRVTEw

       

      However, I have three problems with this method:

       

      1) Photoshop does not send the active tool to plugins at startup.

      2) In some older version of Photoshop, some tools aren't triggering the callback at all.

      3) If the user chooses a tool preset, my callback gets the class string "toolPreset", no matter what type of tool is selected from the preset.

       

      So my question is the following: Is there a better way to get the current active tool?

      Is there by any chance a way of querying it, instead of relying on an event callback?

      I've looked through the plugin API docs but did not find anything that looked relevant.

      Please advise.

       

      Thanks,

      Guillaume

        • 1. Re: How to query active tool?
          kamih Community Member

          Hi,

           

          So after receiving some very useful help and suggestions from Chris Cox and Tom Ruark, here's what I did.

           

          3) I added a new function that uses the Get function from PSActionControlProcs. With this, I am able to correctly query the active tool when I receive a select event callback.

          Here is the code for this function: http://pastebin.com/HSW98Y7g

          Note that this won't work for older versions than CS3.

          2) Nothing I can do for this.

          1) I register an idle event callback at startup, and call my query function during the first callback. I then unregister the idle event callback. If I notice that the query failed, then I assume that this is an older version of PS, and I use the old method during the select event callback.

           

          I hope this helps someone!

          Feel free to contact me if you need more details.

           

          Cheers,

          Guillaume