image thumbnail


version 1.0.1 (10.9 KB) by Todd Baxter
Combined slider and edit textbox control.


Updated 16 Jun 2020

View License


OBJ = SliderEditCombo()
OBJ = SliderEditCombo('Parent', PARENT)
OBJ = SliderEditCombo(___, 'Style', STYLE)
OBJ = SliderEditCombo(___, 'Min', MIN, 'Max', MAX, 'NumSteps', NUMSTEPS)
OBJ = SliderEditCombo(___, 'Values', VALUES)


PARENT (=gcf) <1x1 container handle>
- Handle to parent container (figure, uipanel, etc.) where control will be placed

STYLE (='JSlider') <character vector>
- Specify 'JSlider' or 'Slider' to create a 'javax.swing.JSlider'
control and a single edit textbox control
- Specify 'RangeSlider' to create a 'com.jidesoft.swing.RangeSlider'
control and two edit textbox controls

MIN (=0) <1x1 numeric>
- Minimum value of the range

MAX (=100) <1x1 numeric>
- Maximum value of the range

NUMSTEPS (=1000) <1x1 numeric integer>
- Number of steps to use for the slider to span the range
- Note, actual number of steps used may vary
- Used, along with MIN and MAX, to determine the uniform step size
between values for the slider

VALUES (=[]) <numeric vector>
- Specifies the only values that are selectable in the range, where
the step sizes, in general, will be non-uniform
- Note, specifying the 'Values' argument will take precedence over
specifying any of the 'Min', 'Max', or 'NumSteps' arguments


OBJ <1x1 SliderEditCombo object handle>
- The SliderEditCombo object provides an easy interactive and/or
programmatic way to select values in a range


SliderEditCombo will create a slider and edit textbox user interface
control, where interaction with either control will affect the state of
the other, creating the effect of one combined control. The position
of the slider "thumb" and the value displayed in the edit textbox are
synchronized. When the slider thumb position changes, the edit textbox
string is automatically updated. When a new value is entered into the
edit textbox, the slider thumb position automatically changes.

The slider thumb can be controlled by the mouse and the keyboard. When
a slider is selected/active, the right arrow, up arrow, page up, and
end keys will move the thumb higher, and the left arrow, down arrow,
page down, and home keys will move the thumb lower.

SliderEditCombo's public properties (listed below) can also be used to
programmatically set/get values and configure the control.
- 'Value' is the single slider and edit textbox value
- 'LowValue' is the low slider and edit textbox value
- 'HighValue' is the high slider and edit textbox value
- 'DisplayFormat' specifies how the numeric values will be displayed
in the edit textboxes (see 'sprintf' documentation for more details)
- 'EditTextBoxWidth' is the width of the edit textboxes in pixels
- 'Enabled' determines whether the combined slider and edit textbox
control is enabled or disabled

The SliderEditCombo object also provides an event 'ValueChanged' that
sends a notification when its value changes.

- The combined slider and edit textbox control is sized by the parent
container, i.e. it fills the entire container.
- For the 'Slider' style control, the 'LowValue' and 'HighValue'
properties will set/get the same thing as the 'Value' property.
- For the 'RangeSlider' style control, the 'Value' property will
set/get the same thing as the 'LowValue' property.
- The 'DisplayFormat' property must be valid for displaying numeric
data, or else the SliderEditCombo object's values will not display
properly (see 'sprintf' documentation for more details).


f = figure;
vb = uiextras.VBox('Parent', f);

% slider using min/max/step
h1 = SliderEditCombo('Parent', vb, 'Min', -10, 'Max', 10, 'NumSteps', 50);

% range slider using min/max/step
h2 = SliderEditCombo('Parent', vb, 'Style', 'RangeSlider', 'Min', 10, 'Max', 30, 'NumSteps', 100);

% slider using specified input values
values = [-20, -17, -15, -9, -6, -5, -1, 1, 2, 3, 10, 11, 13, 20];
h3 = SliderEditCombo('Parent', vb, 'Style', 'Slider', 'Values', values);

% range slider using specified input values that are highly non-uniform
values = [logspace(0, 5, 6), 1e5+(1:10)];
values = [-fliplr(values), values];
h4 = SliderEditCombo('Parent', vb, 'Style', 'RangeSlider', 'Values', values);


GUI Layout Toolbox
HG1 version (R2014a and earlier):
HG2 version (R2014b and later):

Cite As

Todd Baxter (2021). SliderEditCombo (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
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!