필터 지우기
필터 지우기

uigetfile breaks modality in uifigures

조회 수: 3 (최근 30일)
Dr D
Dr D 2022년 11월 29일
댓글: Dr D 2022년 12월 8일
I have an app with a main uifigure that does a lot of things. Let's call it the workbench. The workbench calls another uifigure which has its WindowStyle set to 'modal'. This is for input that is required by one of workbench's many steps. Let's call this 2nd uifigure the Filelist.
Normally when Filelist is up, the user cannot access workbench at all. This is good and normal behavior. However, Filelist calls uigetfile(). After the uigetfile dialog goes away, there are two MatLab bugs that occur. The first is minor - some other window gets brought forward - and is easily fixed by calling figure() to bring the Filelist uifigure to the forefront. (See discussion in https://www.mathworks.com/matlabcentral/answers/296305-appdesigner-window-ends-up-in-background-after-uigetfile )
The 2nd bug is not minor. Modality has been broken. The user can now click on workbench while Filelist is open. Filelist is still in control (there's a waitfor() blocking execution) but the user can now interact with workbench's entire UI. The callback in workbench which called Filelist is STILL in operation - it has not been returned to yet from Filelist.
Before the call to uigetfile access to the workbench was blocked. It needs to continue being blocked because the 2nd uifigure is still prompting the user for input. However it's now also possible for the supposedly modal Filelist uifigure to get lost in the background and for the user to continue working with workbench as if the waitfor() had ended and execution had returned. Except that it hasn't returned.
How do I stop this from happening?
Note that I've tried using uiwait() instead of waitfor() with the same result. I've also inspected the Filelist's uifigure object and it still has WindowStyle = 'modal'. I've also tried changing and resetting WindowStyle to re-engage modality. No dice.

답변 (1개)

Eric Delgado
Eric Delgado 2022년 12월 7일
What's Matlab version are you using?! I just test it in R2022b and it's working fine. See app attached.
% app2 button callback
[fileName, filePath] = uigetfile;
figure(app.CallingApp.UIFigure)
figure(app.UIFigure)
(a) app1 normal, app2 modal and an open uigetfiles window:
(b) app1 normal and app2 still a modal:
  댓글 수: 5
Eric Delgado
Eric Delgado 2022년 12월 7일
편집: Eric Delgado 2022년 12월 7일
Check if you are using R2020b Update 8 released on Aug 22, 2022.
https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/updates/r2020b/r2020b-updates-release-notes.pdf
Dr D
Dr D 2022년 12월 8일
Yup. Already up to date. Oh well.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by