Graphics Programs Reference
In-Depth Information
'String','0.5','Style','edit',...
'CallBack',...
'set(hsl,''Value'',str2num(get(hed,''String'')))');
The value from the edit box is transmitted to the slider when you press
return, tab, click outside the edit box, or move the mouse outside the
GUI's window. The slider's callback must convert the slider's value—
a number—to a string before setting the edit box's string property. In
principle the converse is not true. That is, the slider's value property can
be passed directly to the edit box's string property and the number will
be displayed automatically as a string. But we have included a numerical
conversion using num2str(...,2) to limit the number of decimal places
of the displayed value to 2. (What happens when you type nonnumeric
text into the edit box?)
The default limits of a slider are set to a minimum of zero and a
maximum of one. These can be changed via the slider's min and max
properties: the slider's value property is scaled proportionally.
Listbox
Listboxes let you choose from among a scrollable list of alternatives. The
list of alternatives is set by the listbox's string property. The options
for the format of the string are the same as for the axis tick labels (see
page 122); you can specify the alternatives in any of the following ways:
set(h,'String',{'Red';'Green';'Blue'})
set(h,'String','Red|Green|Blue')
set(h,'String',[1;10;100])
set(h,'String',1:3)
set(h,'String',['Red ';'Green';'Blue '])
For example, to bring up a list of colour options:
h = uicontrol('pos',[168 219 89 116], ...
'Style','listbox', ...
'String',{'Red';'Green';'Blue'});
If the list is too wide or high for the listbox, matlab adds scroll sliders:
Search WWH ::




Custom Search