Re: bug with log window

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/bug-with-log-window-tp5022446p5022447.html

Dear Francois,

(and to the group after some private discussion):

Writing to the Log window for the first time brings it to the foreground
(as far as I can say, this has been the case since the early days of
ImageJ).
Essentially it is undetermined when exactly the Log window appears on
the screen; if it happens to appear after the selectImage, then the
front window becomes the Log. These timing issues may depend on the
operating system.

Thus, if one wants to refer to an *image* window, it is always better to
use a method that returns the active *image*, irrespective of non-image
windows, such as the Log. Such java/JavaScript functions are
   IJ.getImage() or
   WindowManager.getActiveImage()

I think that it was not a problem for your macro before version 1.52o30,
where the following code was introduced in the TextWindow class:
                else if (id==WindowEvent.WINDOW_ACTIVATED)
                        WindowManager.setWindow(this);

I guess that this was a bug fix:
Without that code functions that *should* return the front window
(including non-image windows) would sometimes not know that the Log (or
other TextWindows) are in the foreground. Such functions are, e.g., the
macro functions
    getInfo("window.type")
    getInfo("window.title")
    getInfo("window.contents") [for text windows such as the Log]


Michael
________________________________________________________________
On 17.09.19 17:06, François Gannier (Dpt) wrote:

> Dear Michael, Wayne
>
> With the next code,
>
> macro "Test Bug Action Tool - C000T1g06BT8g06uTeg06g" {
>      run("About ImageJ...");
>      run("Duplicate...", " ");
>      dupID = getImageID();
>      IJ.log("loaded...");
>      selectImage(dupID);
>      if (isActive(dupID)) print("true"); else print("false");
>      eval("script","WindowManager.getActiveWindow()");
>      getInfo("window.title");
> }
>
> that's what I get, the first time:
> loaded...
>      true
> ij.text.TextWindow[frame0,26,498,400x388,layout=java.awt.BorderLayout,title=Log,resizable,normal]
>      Log
>
> and the next time:
>      loaded...
>      true
>      About ImageJ-2
>      About ImageJ-2
>
> However, I'm working under a linux distribution with OpenJava 11,
> So I test this on a windows 7 machine with Java 6 and all is working
> correctly, ie the log window stays in background (like version prior to
> 1.52)
> I tried to change java version from 11 to 8 on linux, but the error
> persists (when it is created the log window stole the focus).
>
> I tried to activate the "debug mode" as suggested, but this opens the
> Log window, so the error didn't happened....
>
> Best regards,
> François.
>

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