Add new-position callback to ROI object
addNewPositionCallback
is not recommended. With the new ROIs, use
the addlistener
object function instead. For more information, see
Compatibility Considerations.
adds the function handle id
= addNewPositionCallback(h
,fcn
)fcn
to the list of new-position
callback functions of the ROI object h
. Whenever the ROI object
changes its position, each function in the list is called with the
syntax:
fcn(pos)
pos
is of the form returned by the object's getPosition
method.
The return value, id
, is used only with removeNewPositionCallback
.
Create a rectangle ROI object. Display the position of the rectangle in the title. The title updates when you move the rectangle.
imshow('cameraman.tif')
h = imrect(gca, [10 10 100 100]);
addNewPositionCallback(h,@(p) title(mat2str(p,3)));
Now drag the rectangle using the mouse to observe the callback behavior.
getPosition
| getPositionConstraintFcn
| imroi
| makeConstrainToRectFcn
| removeNewPositionCallback
| setPositionConstraintFcn