Hoe to implement a listener that deletes its calling object?
Show older comments
I would like to trigger DELETE of an IMAGES.ROI object upon ROIMoved event.
I am trying:
figure(1);clf;axis([0 100 0 100])
h = images.roi.Rectangle(gca,'position',uint16([10 20 10 20]));
addlistener(h,'ROIMoved',@(s,~)delete(s))
when the rectangle is moved it gets deleted (as desired) but it also issues an error:
Error using images.roi.Rectangle/MarkDirty
Value must be a handle.
Error in images.roi.internal.ROI/stopDrag
Error in images.roi.internal.ROI
What would be the right way for a listener to delete its object without invoking an error?
Accepted Answer
More Answers (1)
royk
on 12 Jul 2020
0 votes
Categories
Find more on ROI-Based Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!