Clear Filters
Clear Filters

Pop-ups don't appear when starting from AppDesigner

12 views (last 30 days)
I have an app created in AppDesigner, where in the startup function a questdlg should appear asking the user for input.
when I run this from 2021a, the questdlg appear and behaves normally
When I run this from 2022a, the questdlg does not appear until I close the app. Then a popup shows up. Answering the question obviously doesn't help as the instance that it is referring to har now been deleted. I testing this on another computer with 2022a and it works. So I thought it was something with my installation. I reinstalled several times and get the same behavior. I also updated java and restarted my computer several times but still no questdlg at startup.
Does anyone know what this could depend on?
I am running Windows 10
  14 Comments
Thomas Kurian
Thomas Kurian on 21 Dec 2022
Here is the mlapp file. There are lots of subfunctions in separate libraries that I haven't included here, but those can be commented out.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 20 Dec 2022
Edited: Adam Danz on 20 Dec 2022
After reducing your startup function to the following, I could not reproduce the results in MATLAB R2022a.
function startup(app)
answer = questdlg('Test',...
'SAX disconnected...', ...
'No thanks','Yes please','Yes please');
switch answer
case 'Yes please'
disp('YES')
case 'No thanks'
disp('No')
end
end
However, since you are using a binary yes/no question dialog, I recommend using the uiconfirm instead.
answer = uiconfirm(app.UIFigure, ...
strcat('Turn on SAX to... ', app.SAXHostName.Value), ...
'SAX disconnected...', ...
'Options', {'No thanks','Yes please'}, ...
'DefaultOption', 'Yes please');
Some additional tips
  • filesep - instead of the conditions at the top of your startup function
  • fullfile - instead of manually concatenating file path strings
  • Create a private function in your app to do the plotting so your startup function is tidier.
  2 Comments
Image Analyst
Image Analyst on 20 Dec 2022
When would you use uiconfirm, and when would you use questdlg?
Adam Danz
Adam Danz on 20 Dec 2022
Edited: Adam Danz on 20 Dec 2022
There are a family of dialogs built specifically for uifigures and therefore work smoothly with Apps. These dialogs only work with figures created by uifigure().
For a complete list, see Develop uifigure Based Apps > Dialogs and Notifications.
A particularly useful feature is that these dialogs will appear on top of the figure specified in the input arguments unlike the older dialog equivalents whose positions are not affected by the parented figure position. For modal dialogs, the underlying figure will change its display to indicate that a response to the dialog is required.
It is recommended to use these new dialogs when working with uifigures/apps.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!