Hi all,
In a macro, I want to create a dialog with an option Checkbox that determines if a number input box is active (if Checkbox clicked) or inactive (if the Checkbox unclicked). Is it possible to do that in a macro? What I have found in the list about event handling only deals with plugins... Thanks in advance -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Pedro,
This is possible. Dialog.create("Checkbox"); Dialog.addCheckbox("test", true); Dialog.show(); test = Dialog.getCheckbox(); if (test==false) print("false"); Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Pedro J Camello Sent: 04 May 2015 12:46 To: [hidden email] Subject: Control of events in a macro? Hi all, In a macro, I want to create a dialog with an option Checkbox that determines if a number input box is active (if Checkbox clicked) or inactive (if the Checkbox unclicked). Is it possible to do that in a macro? What I have found in the list about event handling only deals with plugins... Thanks in advance -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Pedro J CamelloDr Pedro J Camello
Dear Kees,
thanks for your help. The problem with your code is that it passes the boolean after closing the dialogue; my intend was to change the number of an input box before closing the dialogue Dialog.create("Checkbox"); Dialog.addCheckbox("test", true); Dialog.addNumber("interval", 15); // A number input with a 15 as default that should change to 0 if I un-click the checkbox Dialog.show(); test = Dialog.getCheckbox(); if (test==false) //Here a code to change the number default to 0; Two sequential dialogue boxes would do the job, but I was looking for a more simple way.... Pedro -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Pedro,
> I want to create a dialog with an option Checkbox that determines if a > number input box is active (if Checkbox clicked) or inactive (if the > Checkbox unclicked). I do not know how to do this in a macro, but you can do it with ImageJ2's parameterized command plugins. Here is an example which behaves as you described: https://gist.github.com/ctrueden/7c4764e756c33110f58b Regards, Curtis On Tue, May 5, 2015 at 3:55 PM, Pedro J Camello <[hidden email]> wrote: > Dear Kees, > > thanks for your help. > > The problem with your code is that it passes the boolean after closing the > dialogue; my intend was to change the number of an input box before closing > the dialogue > > Dialog.create("Checkbox"); > Dialog.addCheckbox("test", true); > Dialog.addNumber("interval", 15); // A number input with a 15 as > default that should change to 0 if I un-click the checkbox > Dialog.show(); > test = Dialog.getCheckbox(); > if (test==false) > > //Here a code to change the number default to 0; > > > Two sequential dialogue boxes would do the job, but I was looking for a > more simple way.... > > Pedro > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Pedro J CamelloDr Pedro J Camello
Dear pedro,
So if I understand it well the number input for interval has not to be changed by the user and would only have 2 option 15 or 0? Why put it into a dialog box? interval = 15; Dialog.create("Checkbox"); Dialog.addCheckbox("test", true); Dialog.show(); test = Dialog.getCheckbox(); if (test==false) interval = 0; print(interval); Best wishes Kees -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Pedro J Camello Sent: 05 May 2015 21:55 To: [hidden email] Subject: Re: Control of events in a macro? Dear Kees, thanks for your help. The problem with your code is that it passes the boolean after closing the dialogue; my intend was to change the number of an input box before closing the dialogue Dialog.create("Checkbox"); Dialog.addCheckbox("test", true); Dialog.addNumber("interval", 15); // A number input with a 15 as default that should change to 0 if I un-click the checkbox Dialog.show(); test = Dialog.getCheckbox(); if (test==false) //Here a code to change the number default to 0; Two sequential dialogue boxes would do the job, but I was looking for a more simple way.... Pedro -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Pedro J CamelloDr Pedro J Camello
Dear Kees,
you are right: for only two possible numbers that's the way. But what I was thinking of is to have a single dialogue box to decide: 1) to prune or not a stack (That´s the checkbox option purpose) 2) if prune is desired (Checkbox true) the user can select the interval; otherwise the number box should stay inactive Many thanks for your help Dear Curtis, thanks for your code, is a nice help. Pedr -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Pedro,
a not very elegant but feasible way is a second dialog that comes up if a checkbox is checked/unchecked in the first dialog. Just my two cents. Best Herbie ::::::::::::::::::::::::::::::::::::::::::::: Am 06.05.15 um 20:07 schrieb Pedro J Camello: > Dear Kees, > > you are right: for only two possible numbers that's the way. But what > I was thinking of is to have a single dialogue box to decide: 1) to > prune or not a stack (That´s the checkbox option purpose) 2) if prune > is desired (Checkbox true) the user can select the interval; > otherwise the number box should stay inactive > > Many thanks for your help > > Dear Curtis, > > thanks for your code, is a nice help. > > Pedr > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |