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?

Was it helpful?

Solution

This is happening because you are calling New_window before Main_window has finished executing. Ideas:

  1. You could simply call Main from new instead. I'm guessing that you already tried this and it doesn't work for your application

  2. 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.

  3. 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.

  1. Ultimately, if you want to maximize control, you should write your own gui instead of using GUIDE.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top