Login  Register

Re: More GenericDialog fun

Posted by Michael Schmid on May 11, 2010; 3:26pm
URL: http://imagej.273.s1.nabble.com/More-GenericDialog-fun-tp3688333p3688337.html

Hi Michael,

ok, I see, you read the values (gd.getNextNumber etc.) outside of the  
DialogItemChanged method, that's a situation I did not think about.  
If you have a DialogListener, macro recording works only if you read  
the values in the DialogItemChanged method (getNextNumber, etc.)

Michael
________________________________________________________________

On 11 May 2010, at 16:15, Michael Doube wrote:

> Michael
>
> I tried catching exceptions and none were thrown.  My  
> implementation is pretty simple, as in this example, which adds a  
> listener to a dialog containing a choice menu.  If "voxel" is  
> selected, the numeric field is greyed out (setEnabled(false)) by  
> the dialogItemChanged method.
>
> http://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/ 
> VolumeFraction.java
>
> If I include the DialogListener, options are not recorded.  
> Commenting out gd.addDialogListener restores option recordability  
> (tested on IJ 1.43u and 1.44a8).
>
> Could this be a difference between ItemListeners (which I haven't  
> yet used) and DialogListeners (which I currently use)?
>
> Michael
>
>> this cannot be a general problem with DialogListeners; most filters
>> and some other functions in ImageJ use a DialogListener and get
>> recorded.
>> Maybe your DialogListener causes an exception? You could check it
>> like this:
>> try {
>> ... DialogListener code ...
>> }
>> catch (Exception e) { IJ.log("Exception in DialogListener "+e); }
>>
>> Michael
>> ________________________________________________________________
>>
>> On 11 May 2010, at 13:12, Michael Doube wrote:
>>
>>> Hi all
>>>
>>> Thanks for your very useful comments regarding layout.
>>>
>>> While messing around with layout, I noticed that GenericDialogs
>>> with a dialog listener, added with:
>>>
>>> gd.addDialogListener(this);
>>>
>>> just before:
>>>
>>> gd.showDialog();
>>>
>>> Do not have their options recorded by the Macro Recorder.
>>>
>>> Commenting out gd.addDialogListener(this); restores macro
>>> recordability.
>>>
>>> Is this a known issue, and if so, how can I have dialog listeners
>>> while maintaining macro recordability?