uigetfile breaks modality in uifigures

3 views (last 30 days)
Dr D
Dr D on 29 Nov 2022
Commented: Dr D on 8 Dec 2022
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.

Answers (1)

Eric Delgado
Eric Delgado on 7 Dec 2022
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 Comments
Eric Delgado
Eric Delgado on 7 Dec 2022
Edited: Eric Delgado on 7 Dec 2022
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 on 8 Dec 2022
Yup. Already up to date. Oh well.

Sign in to comment.

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!