Graphics Programs Reference
In-Depth Information
Callbacks are fastest when they are implemented as function calls;
do not implement your callbacks as script m-files or as an eval of a
string. The reason is that matlab compiles a function the first time it
is encountered, whereas m-files and eval s are interpreted line by line.
The button-style uicontrols (pushbuttons, radiobuttons, and check-
boxes) are used by simply clicking on them with the mouse. Others
need more interaction: you must choose an item from a list (listboxes or
popupmenus) or specify a numeric value (sliders) or type in text (edit
boxes). We discuss briefly the operation of each of these different kinds
of uicontrols.
34.2 UIControls
Edit Boxes
Edit boxes are designed to read in a piece of typed text. The text inside
an Edit box is accessed via the box's String property:
h = uicontrol('style','edit','String','Hello');
You can change it using the set command:
or you can click in the box and change it by typing something else. You
can access what has been typed into an edit box by get ting its string
property. After typing qwe into the box you can type:
>> get(h,'string')
ans =
Numbers typed into edit boxes remain strings until you convert them to
>> x = get(h,'string')
>> x+1
ans =
>> str2num(x) + 1
ans =
Good GUIs have instructive text that indicates the function of a uicon-
trol. These can be placed with the text-style uicontrol. In the following
GUIthe “ Name: ”, “ Address: ”, and “ Sex: ” labels are three separate
uicontrols of Text style.
Search WWH ::

Custom Search