Pop-ups don't appear when starting from AppDesigner
14 views (last 30 days)
Show older comments
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
Answers (1)
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
2 Comments
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().
- uiconfirm - similar to questdlg
- uialert - similar to msgbox, errordlg, warndlg
- uiprogressdlg - similar to waitbar
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.
See Also
Categories
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!