Main Content

iptPointerManager

Create pointer manager in figure

Description

example

iptPointerManager(hFigure)creates a pointer manager in the specified figure,hFigure. If the figure contains apointer behavior structure, then the pointer manager controls the pointer behavior for graphics objects in the figure.

UseiptSetPointerBehaviorto associate a pointer behavior structure with a particular object and to define specific actions that occur when the mouse pointer moves over and then leaves the object.

iptPointerManager(hFigure,'disable')disables the figure's pointer manager.

iptPointerManager(hFigure,'enable')enables and updates the figure's pointer manager.

Examples

Create Pointer Manager in Figure with Line Object

Plot a line. Create a pointer manager in the figure. Then, associate a pointer behavior structure with the line object in the figure that changes the mouse pointer into a fleur whenever the pointer is over it.

h = plot(1:10); iptPointerManager(gcf); enterFcn = @(hFigure,currentPoint)set(hFigure,'Pointer','fleur'); iptSetPointerBehavior(h,enterFcn);

Input Arguments

collapse all

图中,指定为一个figureobject.

More About

collapse all

Pointer Behavior Structure

A pointer behavior structure has three fields that specify the behavior of the pointer when the mouse moves over and then exits an object in the figure.

To define the specific actions of the pointer, set the value of these fields to function handles. If you set a field to[], then no action is taken. When the pointer manager calls the function handles, it passes two arguments: the figure object and the current position of the pointer.

Field When Called
enterFcn Called when the mouse pointer moves over the object.
traverseFcn 当鼠标被称为一次pointer moves over the object, and called again each time the mouse moves within the object.
exitFcn Called when the mouse pointer leaves the object.

Tips

  • If a figure already contains a pointer manager, theniptPointerManager(hFigure)does not create a new pointer manager. The syntax has the same behavior asiptPointerManager(hFigure,'enable').

  • iptPointerManagerconsiders not just the object the pointer is over, but all objects in the figure.iptPointerManagersearches the graphics objects hierarchy to find the first object that contains a pointer behavior structure. TheiptPointerManagerthen executes that object's pointer behavior function. For more information, seeGraphics Object Hierarchy.

    For example, you could set the pointer to be a fleur and associate that pointer with the axes. Then, when you slide the pointer into the figure window, it will initially be the default pointer, then change to a fleur when you cross into the axes, and remain a fleur when you slide over the objects parented to the axes.

  • If you specify a pointer behavior usingiptSetPointerBehaviorand then change the figure pointer without usingiptSetPointerBehavior, then theiptPointerManagermay not update to reflect the new behavior. Some ways to change the figure pointer without usingiptSetPointerBehaviorinclude using ROI objects such asPolygon, another graphics object, another custom UI, or code that modifies the pointer from within a callback.

Introduced in R2006a