inputsdlg: Enhanced Input Dialog Box

Predefined dialog box function to accept user inputs of several forms
Updated 30 Jun 2015

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This function is an enhanced version of the standard INPUTDLG function with many additional features:
- 8 control types: text, edit, check, list, range, color, table, button
(**color, table, and button were added in v2.0**)
- Text Type is a static text (e.g., to place an instruction)
- Check Type displays a checkbox with a label, returns one of two values. Value could be logical, integer, or string
- Edit Type can be configured to accept:
* plain text (single- or multi-line mode)
* date (following date formats as defined in DATESTR)
* numeric value (integer or float with attribute specification)
* file or directory name (with UIGETFILE, UIPUTFILE, or UIGETDIR functions, supports UIGETFILE multi-sel
ect mode)
* vector (can specify the length of the vector or the attributes of its elements if the length is fixed or arbitrary). To specify a row vector, include the 'row' keyword in formats.limits field.
- List Type returns index(es) of the selected item and can have 4 different appearances:
* Popupmenu
* Listbox (can be made to multi-select)
* Radiobutton (button placements can be customized)
* Togglebutton (button placements can be customized)
- INPUTSDLG can automatically size controls and dialog box for an optimal appearance, and control's size can be made to auto-adjust if dialog is made resizable.
- INPUTSDLG supports user callbacks to all UI controls as well as dialog's CreateFcn and DeleteFcn callbacks. The callback function takes additional input arguments to standard MATLAB callback arguments.
- INPUTSDLG returns the user entries in a cell or in a structure
- INPUTSDLG is backward compatible with INPUTDLG except for its returned values when canceled. With default answers given, INPUTDLG returns an empty cell while INPUTSDLG returns the default answers. INPUTSDLG returns the second parameter, CANCELED(a logical flag) to indicate how the dialog box is terminated.
- Luke Reisner prepared v1.3 and kindly shared his modification/bug fixes.
- Florian Hatz initiated the development of v2.0 with his ideas of adding table, color, and tiling option

Cite As

Kesh Ikuma (2024). inputsdlg: Enhanced Input Dialog Box (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Bug fix on list control's default value processing

Bug fixes in default value processing

- Allows a row vector with edit:vector format.
- Bug fixes in edit:vector processing

* Added support for 'text' format with 'check' type
* Added support for custom attribute validation for 'edit' type with 'float', 'integer', and 'vector' formats
* Now uses validateattribute() built-in function
* Bug fixes
Title change

* Improved check_formats sub-function

bug fix & extended compatibility to pre-R2011b

v2.1b - same day bug fixes #2

v2.1a (same day bug fixes)

v.2.1.0 (Jul 03, 2014)
* Added support for 'none' Format type as a placeholder for an empty row or column.
* Removed restriction on Cancel & Apply buttons.
* Bug fixes

v2.0.6 - bug fixes
* default type
* text control positioning

updated title

* Improved error message on FORMATS-PROMPT size mismatch.
* Fixed several bugs relating to neglected ToolTipString support (thanks David v.B!)
* FORMATS.items for Slider style now sets uicontrol's SliderStep property

Bug fix: parsing empty callback format field (Thanks David!)

v2.0.3: bug fix release

Made compatible with pre-R2013a releases

Bug fix release

v.2.0 (T. Ikuma & F. Hatz)
* Major update with majority of innards rewritten. See version history in the m-file
* Supports 3 additional types: color, table, and button
* Supports custom callbacks

v1.3 (by Luke Reisner)
* Several bug fixes
* Improved dialog UI layout
* Other small modifications

* Yet another checkoptions() bug fixes...

v.1.2.2 (July 15, 2010)
* Rewritten checkoptions() (to correct issues reported by Jason)
* Bug Fix: file & dir control enable config were interpreted backwards

Bug Fix: Default Options bug reported by Jason

* Fixed a couple bugs
* Added edit::date format
* Added formats.enable support
* Added options.CancelButton support
* Added options.ButtonNames support

(v.1.12) More bug fixes

More bug fixes (again thanks Andreas!)

v1.1 (Nov. 19, 2009)
* Several bug fixes (thanks Andreas!)
* Apply button feature added
* Unit label (to the right of control) feature added