Filter löschen
Filter löschen

Pop-ups don't appear when starting from AppDesigner

12 Ansichten (letzte 30 Tage)
Thomas Kurian
Thomas Kurian am 19 Dez. 2022
Kommentiert: Adam Danz am 21 Dez. 2022
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 Kommentare
Thomas Kurian
Thomas Kurian am 21 Dez. 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.
Adam Danz
Adam Danz am 21 Dez. 2022
Have you tried using uiconfirm?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Adam Danz
Adam Danz am 20 Dez. 2022
Bearbeitet: Adam Danz am 20 Dez. 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 Kommentare
Image Analyst
Image Analyst am 20 Dez. 2022
When would you use uiconfirm, and when would you use questdlg?
Adam Danz
Adam Danz am 20 Dez. 2022
Bearbeitet: Adam Danz am 20 Dez. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by