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 件のコメント
Piero
Piero 2022 年 12 月 7 日
I've same problem :(

サインインしてコメントする。

回答 (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 Center および File ExchangeDevelop 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