Re: "No" button within GenericDialog class feature update

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/No-button-within-GenericDialog-class-feature-update-tp5022458p5022475.html

Hi Fred,

yes, the "OK" button is always enabled at the start, but wouldn't it be
confusing for the user to display a dialog with a disabled OK button?
You would get a disabled OK button only if the default parameters are
invalid (as determined by the dialogItemChanged method), so why suggest
invalid parameters to the user?
Usually, the parameters are taken from the last successful invocation of
the dialog, and there they must have been valid (otherwise there would
have been no way to press ok), or they are predefined parameters (where
it is the programmer's task to suggest reasonable values).
If the now-invalid parameters are from the last invocation (where they
were valid, e.g. because it was a larger image where these coordinates
had been ok), why not correct  these values, to have default parameters
that are valid for the current image? And if there is for some reasons
no way to enter valid parameters (e.g. if you have to enter three
different integer x coordinates of a 1x1 pixel image), there should be
an error message instead of the dialog.

I am not sure whether modifying the GenericDialog to call
dialogItemChanged before the dialog is displayed would be compatible
with all existing plugins, which do not expect such a behavior. The
documentation of the GenericDialog.addDialogListener method specifies
exactly when the DialogListeners get called, and user plugins might rely
on this.


Best,

Michael
________________________________________________________________

On 26.09.19 20:09, Fred Damen wrote:

> Greetings,
>
> On a side note, the dialogItemChanged method returns a boolean which controls
> the enabled / disabled state of the "OK" button.  I use dialogItemChanged in
> part to validate the current field settings and prevent the user from making a
> bogus request. The problem is that the default state of the "OK" button is
> enabled.  I assume that I could go under the hood and disable the "OK" button
> myself before showDialog, albeit, if the form was filled out acceptably the
> user would have to change something to get dialogItemChanged; what I would
> really like is to be able to have the dialogItemChanged method called, and
> "OK" button state determined, before displaying the "OK" button for the first
> time; this would allow the 'is the request valid' code in one place.
>
> Thanks for listening,
>
> Fred

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