Why does gcf in a GUIDE figure give the parent?

3 visualizzazioni (ultimi 30 giorni)
Hello,
I've created a number of GUIDE windows called within one app, and one of them I would like to maximize. I have tested that window with a .m test file, and it works fine using
fh = gcf
fh.Window = 'Maximize'
If I insert this in the overarching GUIDE program (that's also a GUIDE figure), it won't maximize because the calling app figure is non-resizable. Obviously I am missing something regarding how the current figure gets passed to the child.
Thoughts? Thanks!
Doug

Risposta accettata

Walter Roberson
Walter Roberson il 4 Mar 2022
A figure becomes the current figure under any of the following circumstances:
  • the figure is created with figure() [or some routine calling figure() that ends up creating a figure]
  • the figure is made active by calling figure() and passing in a reference to the figure
  • any part of the figure is clicked in (and hit testing is on for any layer of the figure at that location)
If a figure is the current figure and it is deleted, then generally speaking, no other figure will necessarily become the current figure -- they are not defined as "stacking". However, some of the behaviour with creating dialogs such as inputdlg() tends to flow as-if it was going back to the figure that was active at the time the dialog or message was created (those dialogs and pop-up messages are actually figures.) Testing would have to be done to see exactly how that happens.
So... if your overarching GUIDE program is calling into the other GUIDE window because the user clicked something in the overarching GUIDE program... then that overarching GUIDE program became the current figure.
GUIs and figures are the same thing to MATLAB: a GUI is just behaviour attached to a figure, and any figure can have behaviour attached to it.
In your case, if you need the secondary GUIDE program to be able to find its handles by using gcf, then in the overarching program, use figure() passing in the handle of the secondary GUIDE program to make it the current figure.
  1 Commento
Douglas Anderson
Douglas Anderson il 4 Mar 2022
Modificato: Douglas Anderson il 4 Mar 2022
Thank you very much, Walter, once again.
I am not sure how to "use figure() passing in the handle of the secondary GUIDE program". Each of them is created as .fig files, and I have plotted axes (successfully in the test case), so I want to display and print the called figure. The calling program, after a button press, just sends different parameters to this program (plot_spectra) to determine what type of spectrum to plot, and what to do with the plot (print, save, discard, etc.) based upon which button is pressed.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by