Login  Register

Re: Getting the name of a Text Window in a macro

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jul 01, 2014; 5:34pm
URL: http://imagej.273.s1.nabble.com/Getting-the-name-of-a-Text-Window-in-a-macro-tp5008514p5008521.html

On Jul 1, 2014, at 12:51 PM, Michael Schmid wrote:

> Hi Stein,
>
> currently, the ImageJ macro language has a command
>  getInfo("window.type")
> which returns ("Image", "Text", "ResultsTable", "Editor", "Plot", "Histogram", etc.
>  http://rsb.info.nih.gov/ij/developer/macro/functions.html#getInfo-label
>
> As far as I know, there is no function like
>  getInfo("window.name")
> which gives you the name of the current Text Window; we only have getTitle() for image windows.
>
> If Wayne reads this, maybe he will add such a function?

The latest ImageJ daily build (1.49d6) adds a getInfo("window.name") macro function. getInfo("window.title") will also work.

-wayne


> Maybe roughly like this...
>
> ...
> } else if (lowercaseKey.equals("window.name")) {
> Window win = WindowManager.getActiveWindow();
> if (win==null) return "";
> else if (win instanceof Frame) return ((Frame)win).getTitle();
> else if (win instanceof Dialog) return ((Dialog)win).getTitle();
> else return ""; //JWindow or something else?
> }
>
> <the last case is not accounted for in ImageProcessor.getNonImageTitles(); maybe one can omit it>
>
>
> Michael
> ________________________________________________________________
> On Jul 1, 2014, at 15:31, Stein Rørvik wrote:
>
>> Does anyone know how to do do this in a macro:
>>
>> 1)      check if the active window is an image window or a text window or a table window
>>
>> 2)      get the name (title) of the active text window or table window
>> Everything I have tried just ignores text windows and reports the above info from the active image window.
>> It is ok for me to use a java snippet as long as it is callable inside a normal macro.
>> I can provide examples if this question is unclear.
>>
>> Stein
>

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