imrect object - delete notification
4 ビュー (過去 30 日間)
古いコメントを表示
After creating an 'imrect' interactive object, in the context menu there is a delete option. Is there a callback to register when the 'imrect' object is deleted.
What I have so far:
im_rect = imrect(ax, draw_rect);
rectId = addNewPositionCallback(im_rect, @(pos)positionUpdateCallback(pos));
So I have access to the position update callback id. But I don't see how can I register any notifiers for the delete event. There is a 'removeNewPositionCallback', but I don't know whether this callback will be triggered on a delete. I checked both 'imrect' and 'imroi' help sections.
Maybe an alternative would be to add a custom delete command to the context menu, with a callback. Has anyone tried that ?
2 件のコメント
採用された回答
Adam
2016 年 11 月 4 日
編集済み: Adam
2016 年 11 月 4 日
Unfortunately imrect and its similar functions are rather arcaic and don't really conform to more modern Matlab graphics objects, but it does derive from 'handle' and the handle class includes the following event
ObjectBeingDestroyed
which you can listen to as e.g.
addlistener( im_rect , 'ObjectBeingDestroyed', @(src,evt) disp( 'Rectangle died' ) )
6 件のコメント
Adam
2016 年 11 月 4 日
編集済み: Adam
2016 年 11 月 4 日
Can you not catch this under the image load button? If an imrect object is existing and valid when the user loads a new image then do something with the old image to keep it or set some variable so that when the imrect is deleted then you will know whether it was the user deleting it or it being deleted as a result of a new image being loaded.
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!