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

8 visualizaciones (últimos 30 días)
ANDREA BARRI
ANDREA BARRI el 9 de Feb. de 2015
Editada: TED MOSBY el 13 de Jun. de 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

Respuestas (1)

TED MOSBY
TED MOSBY el 13 de Jun. de 2025
Editada: TED MOSBY el 13 de Jun. de 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!

Categorías

Más información sobre App Building en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by