フィルターのクリア

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

15 ビュー (過去 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 Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by