Clear Filters
Clear Filters

Detect when UIfigure is open

37 views (last 30 days)
Rob Campbell
Rob Campbell on 6 Jan 2023
Answered: J. Alex Lee on 6 Jan 2023
I have made a GUI with the AppDesigner. It takes about four seconds after launching the last command in constructor has seemingly completed for the GUI to appear. This somewhat on the long side and so I'd like to make a splash screen that disappears once main the GUI has appeared. However, I don't know what event to listen to in order to make this happen. The Visible property, for instance, is 'on' before the figure itself appears.

Answers (2)

Adam Danz
Adam Danz on 6 Jan 2023
MATLAB currently does not return an indication that rendering is complete but you could use a MATLAB function that requires rendering to be complete for it to execute. In this demo, I use getframe to capture the app figure as soon as it's ready and then the splash screen is deleted.
This is in the app's startup function
fig = figure('Color','r'); % Add your splash screen figure here
getframe(app.UIFigure); % app.UIFigure is the handle to your app figure
Here's an alternative approach to try that would require more work to set up but would be cleaner and more efficient.
  1. Set the visibility of your app components to off from within app designer so that the figure renders quickly but does not initially show any components. If your components are parented to uipanels, then you can just turn off the panel visibility.
  2. Within the startup function, create a spash screen using uiprogressdlg and include the Indeterminate option, then turn visibility on for all components, and finally, close the progress dialog.

J. Alex Lee
J. Alex Lee on 6 Jan 2023
the best i have been able to do is to not use appdesigner itself to create ui components and start the app very bare bones so that the window appears as immediately as possible, then use uiprogressdlg around a manual component creation.
you can still use the appdesigner to lay everything out, and copy the code that gets auto-generated, and wrap that in a function that you can call in the startupfcn,
instead of uiprogressdlg, i have also done apps where i show a uiimage over the entire window to emulate a splash screen, which disappears after the startup fcn has run.
i don't think this really solves the problem of matlab not being able to report when the uifigure element updates are "done" though...


Find more on Develop uifigure-Based Apps in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!