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

6 ビュー (過去 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 Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by