2017-06-03 194 views
1

在保存文件之前,我希望有一個警告對話框。在下面的腳本中,沒有停止按下warndlg OK,並且腳本自動繼續到uiputfile。我如何在它們之間暫停/強制用戶在uiputfile之前按下確定?Matlab GUI中的暫停/用戶輸入(warndlg)問題

腳本:

warndlg('May take time due to image size') 
[file,path] = uiputfile('*.tif', 'Save As'); 
if file == 0 
    return; 
end 

回答

1

可以使用uiwait功能:

uiwait(warndlg('May take time due to image size')) 

它會阻止你的腳本,直到該OK按鈕執行被按下。

希望這有助於

Qapla」

1

您需要任何設置的warndlg'modal'createmode選項:

warndlg('May take time due to image size', 'Warning!', 'modal'); 

warndlg句柄傳遞到uiwait功能暫停程序繼續,直到警告對話框關閉:

hWarn = warndlg('May take time due to image size'); 
uiwait(hWarn);