1) When the user clicks on the "GoTo SecondFig" pushbutton and the new figure appears, the user cannot push again the button on the "MainFigure".
As part of the push button's callback function, disable the button using
app.Button1.Enable = 'off';
...Also, the user is forced to close the second figure if he wants to return to the main one
How are you hiding the first figure? Is the figure embedded within the app or is it external to the app? Either way, within the callback function of the push button from fig 1,
fig1.Visible = 'off';
ax.Visibility = 'off';
Then, set the callback function for Button2 (in fig2) to turn the visibility back on for fig 1.
app.Button1.Visible = 'on';
However, fig2 needs to have access to fig1 handle. Is Fig2 created from the callback function of the button in Fig 1? If so, you could pass the handle there. You may also be able to use find(). Also, see my answer to your question "How do I link these two figures...".
2) When the user clicks on the "Return to MainFig" pushbutton, "SecondFigure" closes and focus return to the main one.
The callback function for Button 2 (in fig 2) will do two things in this order.
- set the Visible property of fig 1 (shown above)
- close the figure using close(f) or delete(f) where f is the handle to figure 2.
(How do I link these two figures in the callback of the "Return to MainFig" pushbutton?)
It depends how they are being created. Figure have a propery UserData where you can store anything you want. You could store the figure handles there. For example,
fig1 = figure();
fig2 = figure('UserData', fig1);
fig1.UserData = fig2;
Now access the figure handles using
fig1.UserData
fig2.UserData
3) Do all this stuff with appDesigner.
It's not clear what you mean here. App Designer is a figure so if you're creating additional figures, those figures must be external. When you say "figure" do you mean "axes" or "tab"?
Best Answer