MATLAB Functions Help Desk

dragrect

Purpose

Drag rectangles with mouse

Syntax

Description

[finalRect] = dragrect(initialRect) tracks one or more rectangles anywhere on the screen. The n-by-4 matrix rect defines the rectangles. Each row of rect must contain the initial rectangle position as [left bottom width height] values. dragrect returns the final position of the rectangles in finalRect.

[finalRect] = dragrect(initialRect,stepSize) moves the rectangles in increments of STEPSIZE. The lower-left corner of the first rectangle is constrained to a grid of size STEPSIZE starting at the lower-left corner of the figure, and all other rectangles maintain their original offset from the first rectangle. [finalRect] = dragrect(...) returns the final positions of the rectangles when the mouse button is released. The default stepsize is 1.

Remarks

dragrect returns immediately if a mouse button is not currently pressed. Use dragrect in a ButtonDownFcn, or from the commandline in conjunction with waitforbuttonpress, to ensure that the mouse button is down when dragrect is called. dragrect returns when you release the mouse button.

Example

Drag a rectangle that is 50 pixels wide and 100 pixels in height.

See Also

rbbox, waitforbuttonpress



[ Previous | Help Desk | Next ]