ROI listener in appdesigner not working

1 view (last 30 days)
Jason
Jason on 17 Jun 2020
Answered: Jason on 17 Jun 2020
Hello. I am using AppDesigner and have an ellipse drawn onto a UIAxes component using:
subplot(1,3,1); hold on
h = images.roi.Ellipse(gca,'Center',[xpeak xpeak2],'Semiaxes',[1.699*fwhm/2 1.699*fwhm2/2],'Color','g','StripeColor','r','LineWidth',1); %1/e^2 = 1.699xfwhm
%el=addlistener(h,'ROIMoved',@allevents); %This doesn't work, causes an error
el=event.listener(h,'ROIMoved',@allevents)
(The ellipse draws fine and I can move it and resize it)
If I've read the documentation correctly, it suggests using event.listener rather than addlistener.
So in function I have:
function allevents(src,evt)
evname = evt.EventName;
switch(evname)
case{'MovingROI'}
disp(['ROI moving Current Center: ' mat2str(evt.CurrentCenter)]);
disp(['ROI moving Current SemiAxes: ' mat2str(evt.CurrentSemiAxes)]);
case{'ROIMoved'}
disp(['ROI moved Current Center: ' mat2str(evt.CurrentCenter)]);
disp(['ROI moved Current SemiAxes: ' mat2str(evt.CurrentSemiAxes)]);
end
end
Howver, Im not getting anything displayed in the command window.

Accepted Answer

Jason
Jason on 17 Jun 2020
OK, got it to work, have include app:
el=event.listener(h,'ROIMoved',@app.allevents)
and
function allevents(app,src,evt)

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!