File Exchange

image thumbnail

AutoWarnDlg

version 1.7.0.0 (18.9 KB) by Jan
Self-terminating modal warning dialog with flashing icon

3 Downloads

Updated 29 Feb 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

A warning dialog is displayed with a flashing exclamation mark. The dialog is
terminated automatically with the default reply, if the user does not press a
button in a specified period of time.
This can be useful e.g. for functions, which are checked with automated tests, because the dialog does not block the execution completely.
Example:
Show a warning for 15 seconds, choose 'Cancel' if time has passed:
Opt.Delay = 15;
Opt.Button = {'Cancel', 'Reject', 'Accept'}; % 1st is default
Opt.Interpreter = 'tex';
Opt.Wrap = false;
[Reply, TimeOut] = AutoWarnDlg({'This is a \bfwarning\rm!', 'Accept, reject or cancel?'}, 'Question', Opt)

Features: Move button focus with the keyboard, copy warning message to the clipboard, flashing icon, text wrapping can be controlled, works even when called from a callback with 'Interruptible' property set to 'off'.

Tested under Matlab 7.7, 7.8, 8.6: HG2

Cite As

Jan (2020). AutoWarnDlg (https://www.mathworks.com/matlabcentral/fileexchange/24871-autowarndlg), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

Shahar

Fantastic!
Great function if you need Matlab temporary dialog box.

Works perfectly in the current release R2009b

Jan

Thanks Matt! 2nd output [TimeOut] is implemented and will be published soon. In addition, more options for the text wrapping are included: none, fixed width in pixels or according to dummy string, auto-wrapping for an approx. 3/2 proportion.

Matt Fig

Works well. One thing I would like to see added is an optional second output which stores whether the dialog terminated due to timeout or user acknowledgment. That way if this was called from a code which was running automatically, the user could be notified that a warning was thrown earlier. This could be useful for debugging.

Jan

03-Aug-2009: Fixed bug in help and example: Delay is triggered by field "Delay", not "Sec".

Updates

1.7.0.0

HG2 supported

1.6.0.0

2nd output: [TimeOut] is TRUE if the timeout was reached. More options for text wrapping.

1.4.0.0

03-Aug-2009: Fixed help section/example: The delay is defined by the field [Opt.Delay] and not [Opt.Sec].

1.3.0.0

Nicer shape of wrapped text.

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux