How to change QUESTDLG code in order to make it 'normal'?

7 vues (au cours des 30 derniers jours)
ANDREA BARRI
ANDREA BARRI le 9 Fév 2015
Modifié(e) : TED MOSBY le 13 Juin 2025
Hi! I would like to interact with other windows before responding to questdlg.
Where I can see the Matlab code of that function?
Thank you in advance.
Andrea

Réponses (1)

TED MOSBY
TED MOSBY le 13 Juin 2025
Modifié(e) : TED MOSBY le 13 Juin 2025
Hi,
The function "questdlg" is designed to be "modal" i.e. it will prevent the user from interacting with other MATLAB windows before responding.
As a workaround you can create a utility based on the function "dialog". Here you can change the "WindowStyle" property to "normal" for your usecase. Below is an example to use it:
function answer = askUser(q,title,buttons,default)
if nargin<2, title = 'Question'; end
if nargin<3, buttons = {'Yes' 'No'}; end
if nargin<4, default = buttons{1}; end
d = dialog('Name',title,'WindowStyle','normal'); % modaless!
uicontrol(d,'Style','text','String',q,...
'Units','normalized','Position',[.05 .55 .9 .35]);
y = numel(buttons);
for k = 1:y
uicontrol(d,'Style','pushbutton','String',buttons{k}, ...
'Units','normalized','Position', ...
[.1+.8*(k-1)/y .1 .8/y-.05 .25], ...
'Callback',@(b,~)setappdata(d,'Answer',buttons{k}));
end
end
You can then call this utility to create your own custom dialog box.
Refer to this documentation for more information on "dialog" :
Hope this helps!

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by