Non-Modal uiconfirm/uialert etc.
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.
Accepted Answer
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.
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!