MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manual de usuario Pagina 382

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 500
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 381
10 Lay Out a Programmatic UI
10-50
4
The button Position is set, returned and placed on the system clipboard:
rect =
37 362 127 27
Add a Position parameter and empty value to the uicontrol command from step 1
in your UI code file, as follows:
btn1 = uicontrol('Style','pushbutton',...
'String','Push Me','Position',[])
With the cursor inside the brackets [], type Ctrl+V to paste the setpos output as
the Position parameter value:
btn1 = uicontrol('Style','pushbutton',...
'String','Push Me','Position',[37 362 127 27])
You cannot call setpos when you are creating a component because setpos requires the
handle of the component as an argument. However, you can create a small function that
lets you position a component interactively as you create it. The function waits for you
to press the mouse button, then calls rbbox, and returns a position rectangle when you
release the mouse button:
function rect = getrect
disp('=== Click and drag out a Position rectangle.')
waitforbuttonpress % So that rbbox does not return immediately
rect = rbbox; % User drags out a rectangle, releases button
clipboard('copy', rect) % Place set string on system
% clipboard as well as returning it
To use getrect:
1
In the editor, place the following statement in your UI code file to generate a push
button. Specify getrect within it as the value for the Position property:
btn1 = uicontrol('Style','pushbutton','String','Push Me',...
'Position',getrect);
2
Select the entire statement in the editor and execute it with the F9 key or by right-
clicking and selecting Evaluate Selection.
3
In the figure window, drag out a rectangle for the control to occupy. When you
have finished dragging, the new component displays in that rectangle. (If you type
a character while you are dragging, rbbox aborts, you receive an error, and no
uicontrol is created.)
4
In the editor, select getrect in the uicontrol statement, and type [] in place of it.
The statement now looks like this:
Vista de pagina 381
1 2 ... 377 378 379 380 381 382 383 384 385 386 387 ... 499 500

Comentarios a estos manuales

Sin comentarios