Receiving mouse clicks in App Designer UIAxes - stops working after imshow

조회 수: 14 (최근 30일)
The attached app has a UIAxes and a "Load" button.
Initialy, when you mouse-click on the UIAxes, the word "Button!" is printed to the Comand Window.
Then after I press "Load," and select a PNG file to load and display, the mouse-click callback no longer seems to be called.
Any ideas?

채택된 답변

Walter Roberson
Walter Roberson 2023년 1월 26일
MATLAB considers graphics objects to be layered. The top-most object that is eligible to receive mouse clicks is typically the one that receives the clicks, unless objects have been specifically configured otherwise.
imshow() creates image() objects, and image() objects are eligible for clicking on, so they typically "hide" the underlying axes.
Lack of a configured mouse click callback for an object does not mean that the mouse click is passed to the next object down for eligibility: instead it means that the object is considered to have accepted the mouse clicks and discarded them.
The behaviour can be controlled by HitTest and PickableParts properties; see the link above.
  댓글 수: 1
David Aronstein
David Aronstein 2023년 1월 26일
Thank you for your help! I still had trouble getting this to work by changing settings on the HitTest and PickableParts for the figure objects, but your help let me to underatand that I can set a ButtonDownFcn callback on the image object:
im = imshow(app.img, 'parent', app.Plot);
set(im, 'ButtonDownFcn', @mouse_click);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by