On Nov 8, 2011, at 5:57 PM, Ved Sharma wrote:
> Basically I want to assign my macro to a shortcut key (e.g. F1), and when I press it, it should change the state of the overlay (hidden<->visible). So in the absence of a "isOverlayHidden" command, the best I can think of is:
>
> //----------------------
> a = random;
> if(a>=0 && a<0.5)
> run("Show Overlay");
> else
> run("Hide Overlay");
> //----------------------
>
> Any ideas if this can be made any better?
The ImageJ 1.46a daily build adds an Overlay.hidden() macro function that can be used to determine if an overlay is hidden or not. Here is an example macro that, when you press "1", shows the overlay if it is hidden, or hides it if it showing:
macro "Toggle Overlay [1]" {
if (Overlay.size==0)
exit("There is no overlay");
if (Overlay.hidden)
Overlay.show;
else
Overlay.hide;
}
-wayne