Can 'uialert' create a modal replaceable dialog like 'warndlg'?

Function like 'warndlg' and 'msgbox' can be used to create a modal replaceable dialog, which means that the old dialog with the same title will be deleted as the new dialog is created.
If other warning dialog boxes have the same title, then MATLAB modifies the most recently active one with the current specifications. MATLAB deletes all other open error, message, and warning dialog boxes with the same dialog box title as the most recently active warning dialog box. The affected dialog boxes can be modal or nonmodal.
I wonder that can uialert create a modal and replaceable dialog?

Answers (1)

Hi @rui,
While the “uialert” function in MATLAB can create a modal dialog box, it does not automatically replace existing dialogs with the same title, unlike “warndlg” or “msgbox.” To manage this, you need to handle the dialogs manually.
You can use the “findall” function to locate any open dialog boxes with a specific title. If any are found, you can close them using the “close” function. After closing the existing dialogs, you can create a new one with “uialert”. This approach ensures that only one dialog with a specific title is open at any time, effectively making the dialog modal but also replaceable.
For more details, you can refer to the official documentation for these functions:
  1. findall - https://www.mathworks.com/help/releases/R2021b/matlab/ref/findall.html
  2. close - https://www.mathworks.com/help/releases/R2021b/matlab/ref/close.html
  3. uialert - https://www.mathworks.com/help/releases/R2021b/matlab/ref/uialert.html
I hope this helps with your question!

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Release

R2021b

Asked:

rui
on 23 Mar 2022

Answered:

on 5 Feb 2025

Community Treasure Hunt

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

Start Hunting!