www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@dialog/showDialog.m
function status = showDialog(obj) %SHOWDIALOG Show the dialog % % STATUS = SHOWDIALOG(OBJ) opens the dialog and blocks execution until it % is closed or until OK or Cancel is pressed. % % Immediately after the dialog is made visible but before it code % execution is blocked, the 'DialogShowing' event is sent. If you want % to execute code after the dialog is visible then you can use a listener % on this event. % % See also xregGui.dialog.closeDialog. % Copyright 2007-2010 The MathWorks, Inc. % Make sure the figure is in the correct position. % Do this first so the everything else gets the final figure size. obj.pSetDialogLocation(); % We actually make everything here. obj.pLayout(); % Add a figure key action to implement Esc capturing. obj.Figure.WindowKeyReleaseFcn = @i_catchEsc; % Add a highlighter for the default action. This also takes care of % handling Enter presses DefaultActionButton = obj.ButtonHandles.(obj.DefaultAction); obj.Figure.setDefaultButton(DefaultActionButton); % Set the CloseRequestFcn. obj.Figure.CloseRequestFcn = {@iFigureCloseRequest, obj.Actions.(obj.CloseAction) }; % And make it visible. obj.Figure.CloseMode = ''; obj.Figure.Visible = 'on'; % Send an event to allow dialog creators to execute custom code after the % dialog is made visible obj.send('DialogShowing', handle.EventData(obj, 'DialogShowing')); TESTMODE = obj.classhandle.Package.TestMode; if ~TESTMODE waitfor(obj.Figure, 'Visible'); elseif TESTMODE callback = obj.classhandle.Package.ShowDialogCallback; xregcallback( callback, obj.Figure, DefaultActionButton ); end % Return the CloseMode status = obj.Figure.CloseMode; % And hide the figure. obj.Figure.Visible = 'off'; function i_catchEsc(src, evt) if get(src, 'CurrentCharacter')==27 close(src); end function iFigureCloseRequest( src, evt, closeAction ) closeAction.execute();