Borrar filtros
Borrar filtros

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

15 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de En. de 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 comentario
David Aronstein
David Aronstein el 26 de En. de 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);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by