Store pointer behavior structure in graphics object
iptSetPointerBehavior(obj, pointerBehavior) stores
the specified pointer behavior structure in the specified graphics
obj is an array
iptSetPointerBehavior stores the same
structure in each object.
When used with a figure’s pointer manager (see
iptPointerManager), a pointer behavior
structure controls what happens when the figure's mouse pointer moves
over and then exits an object in the figure. For details about this
structure, see Pointer Behavior Structure.
iptSetPointerBehavior(obj, ) clears the
pointer behavior from the graphics object or objects.
iptSetPointerBehavior(obj, enterFcn) creates
a pointer behavior structure, setting the
to the function handle specified, and setting the
. See Pointer Behavior Structure for details about these fields.
This syntax is provided as a convenience because, for most common
uses, only the
enterFcn is necessary.
A pointer behavior structure contains three fields:
exitFcn. You set the value of these fields
to function handles and use the
to associate this structure with a graphics object in a figure. If
the figure has a pointer manager installed, the pointer manager calls
these functions when the following events occur. If you set a field
, no action is taken.
|Function Handle||When Called|
|Called when the mouse pointer moves over the object.|
|Called once when the mouse pointer moves over the object, and called again each time the mouse moves within the object.|
|Called when the mouse pointer leaves the object.|
When the pointer manager calls the functions you create, it passes two arguments: the figure object and the current position of the pointer.
Change the mouse pointer to a fleur whenever it is over a specific
object and restore the original pointer when the mouse pointer moves
off the object. The example creates a patch object and associates
a pointer behavior structure with the object. Because this scenario
requires only an
enterFcn, the example uses the
enterFcn) syntax. The example then creates a pointer manager
in the figure. Note that the pointer manager takes care of restoring
the original figure pointer.
patchobj = patch([.25 .75 .75 .25 .25],... [.25 .25 .75 .75 .25], 'r'); xlim([0 1]); ylim([0 1]); enterFcn = @(fig, currentPoint)... set(fig, 'Pointer', 'fleur'); iptSetPointerBehavior(patchobj, enterFcn); iptPointerManager(gcf);
Change the appearance of the mouse pointer, depending on where
it is within the object. This example sets up the pointer behavior
structure, setting the
, and setting
a function named
overMe that handles the position-specific
overMe is an example function (in
that varies the mouse pointer depending on the location of the mouse
within the object. For more information, edit
patchobj = patch([.25 .75 .75 .25 .25],... [.25 .25 .75 .75 .25], 'r'); xlim([0 1]) ylim([0 1]) pointerBehavior.enterFcn = ; pointerBehavior.exitFcn = ; pointerBehavior.traverseFcn = @overMe; iptSetPointerBehavior(patchobj, pointerBehavior); iptPointerManager(gcf);
Change the figure's title when the mouse pointer is over the
object. In this scenario,
used to achieve the desired effect, and
patchobj = patch([.25 .75 .75 .25 .25],... [.25 .25 .75 .75 .25], 'r'); xlim([0 1]) ylim([0 1]) pointerBehavior.enterFcn = ... @(fig, currentPoint)... set(fig, 'Name', 'Over patch'); pointerBehavior.exitFcn = ... @(fig, currentPoint) set(fig, 'Name', ''); pointerBehavior.traverseFcn = ; iptSetPointerBehavior(patchobj, pointerBehavior); iptPointerManager(gcf)