Filter löschen
Filter löschen

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

15 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Jan. 2023
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 Kommentar
David Aronstein
David Aronstein am 26 Jan. 2023
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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by