Graphics Programs Reference
In-Depth Information
The two inner frames are labeled by placing text style uicontrols with the
strings Personal Details and Tax Details at appropriate positions.
Too many frames clutter the GUI. It is often better to use space between
groups of controls to divide them into logical groups.
Slider
Sliders are designed to allow input of a value between two limits. You
input a value by clicking on the central bar and dragging it; by clicking
anywhere between the central bar and the end of the slider, resulting
in a big jump; or by clicking on the arrows at the ends of the slider,
resulting in a little jump. Fiddle with the following slider to see how it
behaves:
h = uicontrol('style','slider');
set(h,'pos',[50 200 450 40])
set(h,'callback','disp(get(h,''value''))')
This slider has its callback property set so as to display the value of the
slider in the command window. The callback is executed when (1) you
release the central bar, (2) you click on the blank area, or (3) you click
on the arrow.
You may want to display the value of a slider in an edit box, or to use
the value typed into an edit box to alter the position of the slider. To
do this you have to get an edit box and a slider to talk to each other to
reveal their properties. The edit box must have a callback that tells the
slider its string property, and the slider must have a callback that tells
the edit box its value property. The following piece of code achieves
this effect:
clf
hsl = uicontrol('Position',[200 260 200 20], ...
'Style','slider','Value',0.5,...
'CallBack',...
'set(hed,''String'',num2str(get(hsl,''value''),2))');
hed = uicontrol('BackgroundColor',[1 1 1], ...
'Position',[200 240 70 20], ...
Search WWH ::




Custom Search