How to make a "Do not touch!" dialog box?

3 ビュー (過去 30 日間)
Csaba 2018 年 2 月 25 日
編集済み: Matt J 2018 年 3 月 4 日
I have a GUI where there are several pushbuttons, selection boxes, etc. By pushing pushbuttons the program calculates something which can be quite long. Users are impatient. When there is no sign of activity on the GUI, they tend to think something is going wrong, so they try to push a different button, then another etc. When the program finishes calculation, it serves the next pushbutton, then the next etc. (depending on how many were pushed by the user). It could be other long calculations and the program is doing one after the second and apparently it becomes insensitive to any user interaction. So the user is complaining that the program "was frozen".
I would like to have a dialogue window, saying that "I am calculating" or something like that, and it would prevent any keyboard or mouse interaction to the main program. Also, it should not let the user close it. It also should let the background calculations go in the GUI.
I have tried different dialog boxes available in MATLAB. All of them either suspend the background calculation, waiting for user interaction or they do not prevent user interaction to the main GUI, and all of them can be closed by the user.
Is there any way to solve this problem?

回答 (2 件)

Matt J
Matt J 2018 年 2 月 25 日
編集済み: Matt J 2018 年 2 月 25 日
You can make the GUI button non-Interruptible using its Interruptible property (if this is a GUIDE GUI). See also Controlling Callback Interruption.
You should in any case disable the other buttons (using their Enable property) while the computation is in progress, and maybe use waitbar() to let the user view the current state of the computation.
  2 件のコメント
Matt J
Matt J 2018 年 3 月 4 日
The number of buttons shouldn't be an issue. You can find and disable all buttons or subsets of buttons in one stroke by doing things like,


Image Analyst
Image Analyst 2018 年 2 月 25 日
What I do is disable all controls, except my exit button, and change the cursor to a wait cursor (spinning blue circle in Windows):
% Change mouse pointer (cursor) to the wait cursor.
drawnow; % Cursor won't change right away unless you do this.
then I re-enable the controls and change the cursor back to normal.
% Change mouse pointer (cursor) to an arrow.
drawnow; % Cursor won't change right away unless you do this.
The attached functions to enable or disable all controls on the window may help.
I'm not aware of the "Interruptible property" Matt mentioned. That may be a better approach - I just don't know because I haven't used it.
  1 件のコメント
Csaba 2018 年 3 月 4 日
Regarding the Pointer:
Actually I have three windows open, and want to have 'busy' pointer on each. So I have issued the following commands:
when I am in fig1.m file (I mean I have issued these commands in fig1.m). What happens is, that fig1 behaves as you said. In fig2 and fig3 the watch appears for a short time but then it changes to 'custom' and then back to 'arrow'.
If I stop at any command and I reissue these commands in the Command Window same happens. I was watching it also on the inspector window. It is necessary to move the cursor to the window (fig2 or fig3) to have these changes. If I do not move it stays 'watch'.
Nevertheless it is not what I want. Can you advise me what is wrong?


Community Treasure Hunt

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

Start Hunting!

Translated by