⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputbox.m

📁 为了下载东西
💻 M
字号:
%
%  Syntax:  inputbox(strTitle,strLabel,strText,strVarName,strUserInput)
%
%  Inputs:  strTitle is the string that will be the title for the input window.  
%           strLabel is the string that will be the label for the editbox.
%           strText is the string that the editbox will contain when displayed.
%           strVarName is a string containing the name of the variable which
%           value is to be altered.
%
%  Result:  If the user clicks the [OK] button, the variable strVarName is set
%           to the numeric value specified by the string contained in the edit-
%           box. If the string is non-numeric, this value is the empty matrix.
%           If the user clicks the [Cancel] button, no changes are made.
%
%  Remark:  Only one inputbox must be open at any one time, otherwise an error
%           will occur, although non-fatal.
%
%           Petur Snaeland, 25.04.1995
%
function inputbox(strTitle,strLabel,strText,cmdOK,strUserInput)

%
%  Read the position of the main program window and store in respective variables:
%
MainPos = get(gcf,'Position');
MainX = MainPos(1); MainY = MainPos(2); MainW = MainPos(3); MainH = MainPos(4);
%
%  Define spacing, width and height of buttons and input window:
%
gap = 10; BtnW = 100; BtnH = 25; BoxW = 250; BoxH = 3*gap+2*BtnH;
%
%  Set up position matrices for the window, editbox and buttons:
%
posBox    = [MainX+(MainW-BoxW)/2 MainY+(MainH-BoxH)/2 BoxW BoxH];
posLabel  = [gap 2*gap+BtnH 150 20];
posEdit   = [180 2*gap+BtnH 50 20];
posOK     = [BoxW/2-BtnW-gap gap BtnW BtnH];
posCancel = [BoxW/2+gap gap BtnW BtnH];
%
%  Define callback strings for the command buttons.  These strings 
%  specify how to respond when the user clicks the buttons.
%
cmdCancel = 'delete(gcf); hUserInput=0;';
%
%  Load and get a handle to the input window, command buttons and editbox.
%  Note that the window isn't displayed until everything is in place.
%
h = figure('Visible','off','NumberTitle','off','MenuBar','none', ...
    'Name',strTitle,'Position',posBox,'Resize','off','Color',[.75 .75 .75] );
hbtnOK     = button('OK',posOK,cmdOK);
hbtnCancel = button('Cancel',posCancel,cmdCancel);    
hlblLabel  = uicontrol('Style','text','String',strLabel,'Position',posLabel, ...
                       'BackgroundColor',[.75 .75 .75],'HorizontalAlignment','center');
hUserInput = editbox(strText,posEdit,cmdOK,strUserInput);
set(h,'Visible','on');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -