How to make uigetfile window pops-up in front of my app (designed in appdesigner)?
Show older comments
Hi Guys,
I use uigetfile to load a file in my app. But its window always ends up behind my app figure. I have tried a couple of solutions suggested in previous threads e.g. using drawnow, but it didn't work. I'm using matlab 2020a.
Is there a way to make uigetfile window show up on top of my app figure without turning my figure off/on?
I would be very grateful if you could share some works around this issue.
Best,
Toey
5 Comments
Peter O
on 18 Apr 2020
Toey,
I'm still on 2019b and can't reproduce the problem. For sanity's sake, can you check what happens with a minimum working example in 2020a to rule out a bug?
In 2019b on Windows, the following MWE produces a file prompt in front of the app window:
1) Use the App Designer to create a blank GUI.
2) Place a button in the center.
3) Assign the uigetfile command to ask for a file on a button click callback.
4) Run the app.
Also, is your main app window a modal one, by chance?
Toey
on 18 Apr 2020
Yen Lee Loh
on 5 Jun 2020
Hi all,
I have the same problem with MATLAB 2019b on macOS.
From talking with a colleague, I believe the issue occurs only on MAC, not Windows.
It would be nice to have a solution/workaround/bugfix!
Yen
Earl Vickers
on 14 Dec 2020
I have the same problem with 2020b on Mac.
Mario Malic
on 14 Dec 2020
I can't find the original question where the workaround for this was posted, but write this after uigetfile or uigetdir
drawnow;
figure(app.ApplicationUIFigure); % replace this with your app handle
Answers (2)
Geoff Martin
on 10 Aug 2023
I'm having exactly the same problem (with uiopen instead of uigetfile) - and the suggested solution seems to do the opposite of a fix.
The uigetfile pop-up pops up BEHIND the app window. So, if you don't know it's there, you won't go looking for it.
the only work-around I've found so far is to make the entire app window invisible (in my case, it's just app.UIFigure)
app.UIFigure.Visible = 'off';
uiopen('load');
app.UIFigure.Visible = 'on';
But this is obviously not very elegant.
Is there a way to move the uigetfile/uiopen window in front of the app window?
Jorg Woehl
on 14 May 2024
0 votes
I have just published a simple workaround for these focus issues, which -- as The MathWorks acknowledges -- still have "currently no official workaround". Check out my File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/165961-fixfocus.
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!