Add new window to OpeningFcn of MATLAB GUI goes to back of main window when running
-
22-12-2019 - |
Question
I have a Main_window
in MATLAB guide. I want open a New_window
when I run Main_window
, So I add this code in OpeningFcn
of Main_window
:
New_window();
When I run Main_window
, New_window
goes to back of Main_window
. I want it in front of Main_window
after running.
Any help?
Solution
This is happening because you are calling New_window before Main_window has finished executing. Ideas:
You could simply call Main from new instead. I'm guessing that you already tried this and it doesn't work for your application
If you want the user to do something with new_window, then proceed to main_window, you could enable uiwait in the new_window opening fcn to keep it in focus until the user closes it.
Create a script that contains two lines
Main_window; New_window;
Running that script will start both programs in sequence, and New_window will be on top.
- Ultimately, if you want to maximize control, you should write your own gui instead of using GUIDE.