5.0

5.0 | 2 ratings Rate this file 131 downloads (last 30 days) File Size: 7.22 KB File ID: #24871

AutoWarnDlg

by Jan Simon

 

29 Jul 2009 (Updated 11 Aug 2009)

Code covered by BSD License  

Self-terminating modal warning dialog with flashing icon

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Download Now | Watch this File

File Information
Description

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 6.5, 7.7, 7.8

MATLAB release MATLAB 7.8 (R2009a)
Zip File Content  
Other Files AutoWarnDlg.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
03 Aug 2009 Jan Simon

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

09 Aug 2009 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.

11 Aug 2009 Jan Simon

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.

01 Oct 2009 Aurelien Queffurust

Works perfectly in the current release R2009b

Please login to add a comment or rating.
Updates
30 Jul 2009

Nicer shape of wrapped text.

03 Aug 2009

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

11 Aug 2009

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

Tag Activity for this File
Tag Applied By Date/Time
gui Jan Simon 30 Jul 2009 10:49:54
dialog Jan Simon 30 Jul 2009 10:49:54
selfterminating Jan Simon 30 Jul 2009 10:49:54
warndlg Jan Simon 30 Jul 2009 10:49:54
warning Jan Simon 30 Jul 2009 10:49:54
debug Jan Simon 12 Aug 2009 10:46:15
potw Shari Freedman 24 Aug 2009 10:25:01
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com