MATLAB Answers

Smooth Multi-window workflow in App Designer

80 views (last 30 days)
Reto Christen
Reto Christen on 4 Apr 2019
Commented: Reto Christen on 9 May 2019
I am building an application with several windows. My goal is to create a workflow which looks like a common "installation workflow" (e.g. installation of Matlab).
My app works, but I have some graphical issues while opening the new window.
When I hit "Next"-Button on my first GUI (let's call it GUI1), the following code is called:
% Button pushed function: Next
function NextButtonPushed(app, event)
% start GUI2 window
GUI2(app, app.GUI1.Position);
end
This opens GUI2 with the following start-up function:
% Code that executes after component creation
function startupFcn(app, appBefore, position)
% copy subject (struct of data) to new app
app.subject = appBefore.subject;
% get same position as app before + [Menu Bar shift]
app.GUI2.Position = position + [0 22 0 0];
% close app before
delete(appBefore);
end
This works fine while debugging step-by-step. As soon as I run it without debugging, I have a problem with closing my first app (GUI1). In my opinion GUI1 should be closed after GUI2 is loaded, therefore, we should not even see GUI1 closing. For the user it should be more like another page. Unfortunately, while running the apps normally GUI1 is closing even before GUI2 is plotted. I believe this must be a graphical issue (small delay with plotting the new window). A pause() statement before delete(appBefore) actually does what I want. Unfortunately, the delay time is quite random, which makes it unusable. Is there a solution to wait until the app is loaded completely before executing delete(appBefore)?
Another small issue is this menu bar shift. I do not really understand why having a menu bar increases my window size after the first time it is plotted. So far, I could not find a better workaround than adding this shift.
I would appreciate any help. Thanks a lot.

  1 Comment

Reto Christen
Reto Christen on 9 May 2019
The command drawnow; helped solving the delay problem.
% Code that executes after component creation
function startupFcn(app, appBefore, position)
% copy subject (struct of data) to new app
app.subject = appBefore.subject;
% get same position as app before + [Menu Bar shift]
app.GUI2.Position = position + [0 22 0 0];
drawnow;
% close app before
delete(appBefore);
end

Sign in to comment.

Answers (0)

Sign in to answer this question.