NBUTTONDLG: A Generic Implementation of QUESTBOXDLG
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 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
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. |
|