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

조회 수: 3 (최근 30일)
ANDREA BARRI
ANDREA BARRI 2015년 2월 9일
편집: TED MOSBY 2025년 6월 13일
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

답변 (1개)

TED MOSBY
TED MOSBY 2025년 6월 13일
편집: TED MOSBY 2025년 6월 13일
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!

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by