removeNewPositionCallback
Remove new-position callback from ROI object
removeNewPositionCallback
is not recommended. With the new ROIs,
use the addlistener
object function instead. For more information,
see Version History.
Description
Examples
Add and Remove New Position Callback
Create a line ROI object. Display the position of the line in the title.
Use addNewPositionCallback
to update the title each time you
move the line.
imshow("pout.tif")
h = imline(gca,[10 100],[100 100]);
id = addNewPositionCallback(h,@(pos) title(mat2str(pos,3)));
Move the line to observe the callback behavior.
After observing the callback behavior, remove the callback. The title no longer changes when you move the line.
removeNewPositionCallback(h,id);
Input Arguments
Version History
Introduced in R2008aR2018b: removeNewPositionCallback
is not recommended
Starting in R2018b, a new set of ROI objects replaces the existing set of ROI objects. The new objects provide more functional capabilities, such as face color transparency. The new classes also support events that you can use to respond to changes in your ROI such as moving or being clicked. Although there are no plans to remove the old ROI objects at this time, switch to the new ROIs to take advantage of the additional capabilities and flexibility. For more information on creating ROIs using the new ROI functions, see Create ROI Shapes.
With the new ROIs, the Position
property contains the current
location of the ROI. To receive notification when this value changes, set up a
listener using the addlistener
object
function. To remove this callback, delete the listener object.
Update all instances of removeNewPositionCallback
.
Discouraged Usage | Recommended Replacement |
---|---|
This example uses the
imshow("cameraman.tif") h = imrect(gca, [10 10 100 100]); % Add callback that updates the title with position. id = addNewPositionCallback(h,@(p) title(mat2str(p,3))); % Remove position callback. Title no longer updates. removeNewPositionCallback(h,id); | Here is equivalent code, creating a new ROI object and
replacing the imshow("cameraman.tif") h = drawrectangle(gca,"Position",[10 10 100 100]); % Set up a listener for ROI moving events. el = addlistener(h,"MovingROI",@mymovecb) % Callback to update title with current position function mymovecb(src,evt) currpos = evt.CurrentPosition; title(mat2str(currpos,3)) end |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)