How to make a "Do not touch!" dialog box?
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
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.
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.
set(gcf,'Pointer','watch');
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.
set(gcf,'Pointer','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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dialog Boxes 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!