(app designer) Callback for ROIMoved event does not work

19 ビュー (過去 30 日間)
Thomas Johansson
Thomas Johansson 2020 年 4 月 17 日
コメント済み: Dennis Premoli 2023 年 5 月 29 日
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.

採用された回答

Tommy
Tommy 2020 年 4 月 17 日
Thomas,
When setting up the listener, use
addlistener(ROI, 'ROIMoved', @app.allevents)
Then, when defining allevents, use
function allevents(app, src, event)
...
end
  7 件のコメント
Khaleel Alhalaseh
Khaleel Alhalaseh 2021 年 4 月 15 日
up vote for a thorough answer. salute
Dennis Premoli
Dennis Premoli 2023 年 5 月 29 日
THank you very much!! Retainign the (src,evt) is also important indeed.

サインインしてコメントする。

その他の回答 (1 件)

Heather Wannarka
Heather Wannarka 2021 年 7 月 8 日
This thread is incredibly helpful! It works beautifully in an app created in App Designer 2021a. I am now trying to implement an identical design in an older GUIDE interface and am getting an error similar to the original poster.
Error using images.roi.Rectangle/addlistener
Event 'addNewPositionCallback' is not defined for class 'images.roi.Rectangle'.
Error in RCSTool>DrawShape_Callback (line 757)
addlistener(H, 'addNewPositionCallback', @app.allevents)
Does GUIDE require a different class setup? I have been digging through forums and can find no better explaination than this one and I don't see any reason why it should not work. Any thoughts would be deeply appreciated.

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by