bug/oversight in NonBlockingGenericDialog

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

bug/oversight in NonBlockingGenericDialog

Jim Passmore-2
Think I've found a bug in NonBlockingGenericDialog, in that it doesn't
handle the yes/no/cancel option.  I was writing a jython sript in Fiji, but
this simplified javascript example shows the problem as well.

moreDialog = GenericDialog("Title here");
moreDialog.addMessage("text here");
moreDialog.enableYesNoCancel();
moreDialog.showDialog();
IJ.log ("responded");
if (moreDialog.wasOKed())
    {
    IJ.log ("pressed Yes");
    }
else if (moreDialog.wasCanceled())
    {
    IJ.log ("pressed cancel");
    }
else
    {
    IJ.log ("pressed no");
    }

If you run this, you get exactly what you expect.  For each button, the
word "responded" gets written to the log window, followed by the statement
of which button was pressed.  However, if you substitute the following
first line, to make it non-modal...

moreDialog = NonBlockingGenericDialog("Title here");

then pressing yes & cancel both still work, logging "responded" and the
appropriate button statement.  When you press the "no" button, the dialog
closes, but nothing gets written to the log window.  At first I thought it
was just stopping the script, but I was running this in Fiji's script
editor, which includes buttons to run and kill the script.  I noticed that
even though the dialog is dismissed, the Fiji run botton is still gray, and
the kill button is still available.  When I pressed "kill", I then saw the
"responded/pressed no" lines in the log window.

I figure it's an event handling issue, but I'm not java-savvy enough to fix
it...

(Running this on 32-bit Win7 Pro, 32-bit Java 1.6.0.24, and ImageJ 1.46j as
updated by Fiji.)

--
*Jim Passmore
*Linux User #232777
Reply | Threaded
Open this post in threaded view
|

Re: bug/oversight in NonBlockingGenericDialog

Rasband, Wayne (NIH/NIMH) [E]
On May 7, 2012, at 11:53 AM, Jim Passmore wrote:

> Think I've found a bug in NonBlockingGenericDialog, in that it doesn't
> handle the yes/no/cancel option.  I was writing a jython sript in Fiji, but
> this simplified javascript example shows the problem as well.

This bug is fixed in the ImageJ 1.46n daily build.

-wayne

> moreDialog = GenericDialog("Title here");
> moreDialog.addMessage("text here");
> moreDialog.enableYesNoCancel();
> moreDialog.showDialog();
> IJ.log ("responded");
> if (moreDialog.wasOKed())
>    {
>    IJ.log ("pressed Yes");
>    }
> else if (moreDialog.wasCanceled())
>    {
>    IJ.log ("pressed cancel");
>    }
> else
>    {
>    IJ.log ("pressed no");
>    }
>
> If you run this, you get exactly what you expect.  For each button, the
> word "responded" gets written to the log window, followed by the statement
> of which button was pressed.  However, if you substitute the following
> first line, to make it non-modal...
>
> moreDialog = NonBlockingGenericDialog("Title here");
>
> then pressing yes & cancel both still work, logging "responded" and the
> appropriate button statement.  When you press the "no" button, the dialog
> closes, but nothing gets written to the log window.  At first I thought it
> was just stopping the script, but I was running this in Fiji's script
> editor, which includes buttons to run and kill the script.  I noticed that
> even though the dialog is dismissed, the Fiji run botton is still gray, and
> the kill button is still available.  When I pressed "kill", I then saw the
> "responded/pressed no" lines in the log window.
>
> I figure it's an event handling issue, but I'm not java-savvy enough to fix
> it...
>
> (Running this on 32-bit Win7 Pro, 32-bit Java 1.6.0.24, and ImageJ 1.46j as
> updated by Fiji.)
>
> --
> *Jim Passmore
> *Linux User #232777