Quantcast

How to set focus to s specific image in a plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to set focus to s specific image in a plugin

Lambacher, Armin
Hello Everybody,

I do some evaluations on an image and upon certain keypresses a result is added to a ResultsTable. After that I want to get the focus back to the original image again. I tried to understand the logics of the WindowManager, but it seems that I fail in that respect.

Here’s a code snippet, the whole code is to big to attach. The function “_createBleachingResult()” will add the current result to the ResultsTable (creating the ResultsTable upon first call). After adding the result I call the show() function of the table to update the screen representation. Then I try to get the focus back to the _sourceImage. When debugging, the content of win seems resonable, as the debugger shows the correct title of the _sourceImage in the win variable. But neither “setCurrentWindow” nor “setWindow” bring the focus back to the _sourceImage.



                _createBleachingResult(bd);
               
                if( _bleachingResultsTable != null )  
                {
                        _bleachingResultsTable.show("Bleachings");
                }
               
                // after bleaching is added, we try to set focus to the image again
               
                ImageWindow win = ij.WindowManager.getImage(_sourceImage.getTitle()).getWindow();

                IJ.wait(100);
               
                ij.WindowManager.setCurrentWindow(win);

                ij.WindowManager.setWindow(ij.WindowManager.getWindow(_sourceImage.getTitle()));




Can anybody please enlighten me?

Best

Armin


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set focus to s specific image in a plugin

Jerome Mutterer-3
Hi Armin,
Selecting image windows by title isn't safe, as you might have several
images with the same title. Selecting by image id is better as each image
has a unique id.

In short, you can get an image id with:

  int id = imp.getID();

and later select it with:

  IJ.selectWindow(id);

Sincerely,
Jerome

2017-02-03 16:14 GMT+01:00 Lambacher, Armin <[hidden email]>:
>
> Hello Everybody,
>
> I do some evaluations on an image and upon certain keypresses a result is
added to a ResultsTable. After that I want to get the focus back to the
original image again. I tried to understand the logics of the
WindowManager, but it seems that I fail in that respect.
>
> Here’s a code snippet, the whole code is to big to attach. The function
“_createBleachingResult()” will add the current result to the ResultsTable
(creating the ResultsTable upon first call). After adding the result I call
the show() function of the table to update the screen representation. Then
I try to get the focus back to the _sourceImage. When debugging, the
content of win seems resonable, as the debugger shows the correct title of
the _sourceImage in the win variable. But neither “setCurrentWindow” nor
“setWindow” bring the focus back to the _sourceImage.

>
>
>
>                 _createBleachingResult(bd);
>
>                 if( _bleachingResultsTable != null )
>                 {
>                         _bleachingResultsTable.show("Bleachings");
>                 }
>
>                 // after bleaching is added, we try to set focus to the
image again
>
>                 ImageWindow win =
ij.WindowManager.getImage(_sourceImage.getTitle()).getWindow();
>
>                 IJ.wait(100);
>
>                 ij.WindowManager.setCurrentWindow(win);
>
>
ij.WindowManager.setWindow(ij.WindowManager.getWindow(_sourceImage.getTitle()));

>
>
>
>
> Can anybody please enlighten me?
>
> Best
>
> Armin
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html




--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
www.ibmp.cnrs.fr

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