MATLAB: (app designer) Callback for ROIMoved event does not work

addlistenerapp designercallbackevent

Hi,
I have modified the Matlab app 'Image histogram example' with the possibility to draw an ROI and get the histogram of that part of the image. It works when I draws the ROI but when I moves the ROI I got the below error:
Warning: Error occurred while executing the listener callback
for event ROIMoved defined for class images.roi.Rectangle:
Undefined function 'allevents' for input arguments of type
'images.roi.Rectangle'.
> In images.roi.internal/ROI/stopDrag
In images.roi.internal.ROI
I have tried several alternatives from this forum but nothing works.
Below is a sceen shot from the code view with the relevant part visible.

Best Answer

Thomas,
When setting up the listener, use
addlistener(ROI, 'ROIMoved', @app.allevents)
Then, when defining allevents, use
function allevents(app, src, event)
...
end