Non-Modal uiconfirm/uialert etc.
8 views (last 30 days)
Show older comments
Is there a way to make the newer style dialog boxes like uiconfirm non modal?
I was using the jFrame method until recently but I am moving my app to a new matlab version where using jFrames directly is deprecated.
Is there a way, apart from making my own dialog boxes, to change the windowStyle? The property is not accessable and I didn't find a way to get the handle to the dialog box.
0 Comments
Accepted Answer
Aravind
on 4 Feb 2025
The newer dialog boxes, like “uialert,” allow you to set the modality, eliminating the need to use the deprecated and unsupported “jFrames” method. According to the documentation, you can set the “Modal” parameter of the “uialert” dialog box to “false” to make it non-modal. You can find more details here: https://www.mathworks.com/help/releases/R2021a/matlab/ref/uialert.html#buzsie2-1-Modal.
However, as per the documentation at https://www.mathworks.com/help/releases/R2021a/matlab/ref/uiconfirm.html the “uiconfirm” dialog box does not seem to have a property to control its modality. This design choice makes sense, as the purpose of “uiconfirm” is to ensure user confirmation before proceeding. So skipping it would defeat its purpose.
If you want the customizability of “uiconfirm” but still wish to allow users to skip the dialog box, you might consider designing your own dialog using “uifigure,” “uilabel,” “uibutton,” and other components to achieve the desired functionality.
I hope this helps clarify your question!
More Answers (1)
Anay
on 4 Feb 2025
Hi Norbert.
Dialog boxes produced by “uiconfirm” and “uialert” are always modal and this nature cannot be changed. As you mentioned, one solution to create non-modal dialog boxes would be to create your own dialog box using “uifigure”. Alternatively, you can use “uigetpref” to create non-modal dialog boxes. Use the following code for reference:
[pref_val, is_opened] = uigetpref('myGroup', 'myPref', 'my dialog box title',...
['dialog question Sample question ...' ...
'dialog question Sample question'], {'button', 'labels'});
This will open a non-modal dialog box like this:

“pref_val” contains the option selected by user.
But it comes with a catch. The “Do not show this dialog again.” checkbox cannot be removed from “uigetpref”. This is likely because “uigetpref” is used to get and store user preference. If this checkbox is checked, this dialog box will not be shown again for that preference. In terms of our example, if the checkbox is checked before selecting an option, you will not be able to call “uigetpref” again with preference set to “mypref”. One workaround for this problem can be to call:
uisetpref('clearall')
This will clear all the preferences thus enabling you to call dialog with same preference again and again even if user checks the “Do not show again” dialog box. You can refer to the documentation of “uigetpref” in the MATLAB version R2021a by following this link.
Hope this helps.
See Also
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!