NBUTTONDLG: A Generic Implementation of QUESTBOXDLG

版本 1.0.0.0 (5.0 KB) 作者: sco1
Generates an n-button question dialog box
76.0 次下载
更新时间 2022/10/12

An expansion over QUESTBOXDLG, which allows up to 3 button selections, NBUTTONDLG(Question, ButtonLabels) creates a modal dialog box that sizes to accomodate a generic number of buttons. The number of buttons is determined by the number of elements in buttonlabels, a 1xn cell array of strings. The name of the button that is pressed is returned as a string in userchoice. NBUTTONDLG will theoretically support an infinite number of buttons. The default parameters are optimized for 4 buttons.
NBUTTONDLG returns the label of the selected button as a character array. If the dialog window is closed without a valid selection the return value is empty.
NBUTTONDLG uses UIWAIT to suspend execution until the user responds.
Example:
UserChoice = nbuttondlg('What is your favorite color?', ...
{'Red', 'Green', 'Blue', 'Yellow'} ...
);
if ~isempty(UserChoice)
fprintf('Your favorite color is %s!\n', UserChoice);
else
fprintf('You have no favorite color :(\n')
end

The Question and ButtonLabel inputs can be followed by parameter/value pairs to specify additional properties of the dialog box. For example, NBUTTONDLG(Question, ButtonLabels, 'DialogTitle', 'This is a Title!') will create a dialog box with the specified Question and ButtonLabels and replace the default figure title with 'This is a Title!'

引用格式

sco1 (2024). NBUTTONDLG: A Generic Implementation of QUESTBOXDLG (https://github.com/StackOverflowMATLABchat/nbuttondlg), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2009b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Dialog Boxes 的更多信息

Community Treasure Hunt

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

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.0.0.0

Update version requirement from R2007a to R2009b due to use of tilde operator in function calls.

Fixed handle graphics compatibility issues requiring R2014b or later. Should now work with MATLAB 2007a and later.

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库