User`s guide
Compose and Code GUIs with Interactive Tools
You can obtain the new property value by running the ge t function:
value = get(object_handle, 'PropertyName')
Transfer the value to your GUI program file. Either include it as a
parameter-value pair in the statement creating the object, or as a
set
command for it later in the file. For some tools and techniques that aid i n
programming properties, see “G ene rat e Code t o Se t Compone nt Pro pe rties ”
on page 11-64.
Sketch a Position Vector
rbbox is a useful function for setting positions. When you call it, you drag out
a rubber band box anywhere in the figure. You receive a position vector for
that box when you release the mouse button. Be aware that when
rbbox
executes,
• A figure window must have focus.
• Themousecursormustbewithinthefigurewindow.
• Your left mouse b utton must down.
Because of this behavior, you must call
rbbox from a function or a script that
waits for you to press the m ouse button. The returned position vector specifies
the rectangle you draw in figure units. The following function, called
setpos,
calls
rbbox to specify a position for a component. It returns the position vector
you drag out and als o p laces it on the system clipboard:
function rect = setpos(object_hand le)
% Use RBBOX to establish a position for a GUI component.
% object_han dle is a handle to a uicomponent t hat uses
% any Units. Internally, figure Units are used .
disp(['=== D rag out a Position for object ' in putname(1)])
waitforbuttonpress % So that rbbox does not r etu rn immediately
rect = rbbox; % User drags out a rectangl e, releases button
% Pressing a key aborts rbb ox, so check for null width & height
if rect(3) ~= 0 && rect(4) ~= 0
% Save and restore original un its for object
myunits = get(object_handle,'Units ');
set(object_handle,'Units',get(gcf,'Uni ts'))
11-49