Login  Register

Re: Action Tool Icon Toggle

Posted by Alan Brooks on Jan 16, 2021; 5:21am
URL: http://imagej.273.s1.nabble.com/Action-Tool-Icon-Toggle-tp5024376p5024379.html

Thanks, Wayne. This API is exactly what I was after.

I also see the visual flickering and sometimes also see the blue square / red circle update again when I interact with a different tool such as switching from the Rectangle to Oval selection tool. It is as if the some clicks are missed and they catch up the next time I interact with the Toolbar?

Alan


> On Jan 15, 2021, at 9:07 PM, Wayne Rasband <[hidden email]> wrote:
>
>> On Jan 15, 2021, at 8:51 AM, Alan Brooks <[hidden email]> wrote:
>>
>> Is there a way to dynamically update the icon for an action tool from a Java PlugIn or Macro PlugIn? I am making a tool that toggles between two states and I’d like to update the icon to represent the state.
>
> The latest daily build (1.53h46) adds a Toolbar.setIcon(name,icon) method that allows macros and plugins to update tool icons. The action tool below uses this method to toggle between blue square and red circle icons. I am trying to figure out why the icon sometimes flashes when it is updated.
>
> -wayne
>
>
>  var state = 1
>
>  macro "Toggle Icon Action Tool - C00cF00ff" {
>       if (state==1) {
>          call("ij.gui.Toolbar.setIcon", "Toggle Icon Action Tool", "Cc00V00ff");
>          state = 2;
>       } else {
>          call("ij.gui.Toolbar.setIcon", "Toggle Icon Action Tool", "C00cF00ff");
>          state = 1;
>       }
>  }
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html