Non-Modal uiconfirm/uialert etc.

10 次查看(过去 30 天)
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.

采纳的回答

Aravind
Aravind 2025-2-4
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!
  1 个评论
Norbert
Norbert 2025-2-5
Thanks for your answer. I had missed the modal option on the uialert. However I neglectedto mention in my original description that I want the dialogs to be always on top and non modal, so that users can correct/investigate in the main app whatever the dialog is saying before proceeding. I guess the only option there is to make the dialogs myself.

请先登录,再进行评论。

更多回答(1 个)

Anay
Anay 2025-2-4
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.
  1 个评论
Norbert
Norbert 2025-2-5
Thank you very much for your suggestion. I'll keep that one in mind. Might be useful.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by