Posted by
Stein Rørvik on
Oct 11, 2020; 9:11am
URL: http://imagej.273.s1.nabble.com/Non-modal-dialog-with-Yes-No-Cancel-tp5024006p5024009.html
Same effect as my first example, but still modal, which is my problem.
I need to change between images while the dialog is open to inspect them.
Stein
-----Original Message-----
Sent: 10. oktober 2020 13:25
Subject: Re: Non-modal dialog with Yes No Cancel
Dear Stein,
What about:
do{ //do some processing here, creating results to be inspected
reply = getBoolean("Are the results ok?", "Yes", "No");
} while(!reply)
// continue
Best wishes
Kees
Dr Ir K.R. Straatman
Advanced Imaging Facility
University of Leicester
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.le.ac.uk%2Fadvanced-imaging-facility&data=02%7C01%7Cstein.rorvik%40sintef.no%7C8f8eed6e75374487464208d86d0f52ac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637379259882198793&sdata=uH5wvfqgMtBSCjxy5cxlHABVPV7O%2Bi3jalQer9dS1UI%3D&reserved=0<
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.le.ac.uk%2Fadvanced-imaging-facility&data=02%7C01%7Cstein.rorvik%40sintef.no%7C8f8eed6e75374487464208d86d0f52ac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637379259882198793&sdata=uH5wvfqgMtBSCjxy5cxlHABVPV7O%2Bi3jalQer9dS1UI%3D&reserved=0>
Sent: 09 October 2020 19:58
Subject: Non-modal dialog with Yes No Cancel
I am looking for a non-modal version of a Yes/No/Cancel dialog to use in a macro.
I need a "No" choice that will provide the option to redo the processing instead of continuing or canceling, as the processing involves some manual input that can be adjusted.
We have a getBoolean(message, yesLabel, noLabel) function which basically does what I want,
but I need a non-modal dialog since the user should be allowed to select different windows to inspect that the results of the macro execution is as expected before continuing.
Here is an example flow with the existing getBoolean dialog:
//yes-no-cancel dialog works as desired, but it is only available modal
reply = false;
while (!reply) {
//do some processing here, creating results to be inspected
reply = getBoolean("Are the results ok?", "Yes", "No");
}
//continue
We have a Dialog.createNonBlocking function that creates a non-modal dialog, but I find no way to add Yes / No / Cancel buttons to it.
We can add a checkbox, but it looks clumsy:
//workaround using checkbox
no = true;
while (no) {
//do some processing here, creating results to be inspected
Dialog.createNonBlocking("Verify");
Dialog.addMessage("Are the results ok?");
Dialog.addCheckbox("No", no);
Dialog.show();
no = Dialog.getCheckbox();
}
//continue
We can also use radio buttons, but that looks equally clumsy:
//workaround using radio buttons
reply = "No";
while (reply == "No") {
//do some processing here, creating results to be inspected
Dialog.createNonBlocking("Verify");
Dialog.addMessage("Are the results ok?");
Dialog.addRadioButtonGroup("Reply", newArray("Yes", "No", "Cancel"), 1, 3, reply);
Dialog.show;
reply = Dialog.getRadioButton;
if (reply == "Cancel") exit;
}
//continue
Any ideas?
Some JavaScript that can create the desired non-modal Yes/No/Cancel dialog?
The best solution would be if we could have a way to add custom buttons in the Dialog.* functions in the macro language,
like Dialog.addButton(text, isDefault).
I am not sure the best way to have a return value from that, perhaps by passing a return value to Dialog.show;
or having a Dialog.getButton() function that returned the label of the custom button that was pressed on dialog exit.
Then one could add buttons named like "Redo" or "Continue " which could lead to a different action than "OK" or "Cancel".
Stein
--
ImageJ mailing list:
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no%7C8f8eed6e75374487464208d86d0f52ac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637379259882198793&sdata=VCnsk%2BDwWTisYh00k%2FMFqgCc86SYwnHiBFU4Ai0%2F8jU%3D&reserved=0--
ImageJ mailing list:
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no%7C8f8eed6e75374487464208d86d0f52ac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637379259882198793&sdata=VCnsk%2BDwWTisYh00k%2FMFqgCc86SYwnHiBFU4Ai0%2F8jU%3D&reserved=0--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html