ButtonDownFunction on an image in App Designer

40 vues (au cours des 30 derniers jours)
Salad Box
Salad Box le 18 Nov 2021
Commenté : Salad Box le 22 Nov 2021
Hi
I haven't really figured out how to use the 'BottonDownFcn' on an image in the new App Designer.
Here is what I would like to achieve. I click on the top button to load an image, then an image is loaded on the left with a single blue colour (to make things super simple), then I am hoping to apply the buttondown function on this image on the left. How should I do it and where should I put the code, in the top button's callback or somewhere else?
Please can someone give me some advices?

Réponse acceptée

Cris LaPierre
Cris LaPierre le 19 Nov 2021
Modifié(e) : Cris LaPierre le 19 Nov 2021
Use the axes ButtonDown callback function (added to app designer in R2020b). Rt click on the UIAxes and select 'Callbacks > add UIAxesButtonDown callback function'.
Whatever code you want to execute when you left click on the image goes in this callback function.
There is some setup to get this to work with an image. Namely, you need to set the image object HitTest property to 'off'. There are a number of ways to do this. The default UIAxes callback execution control properties should be set correctly already (worked for me at least).
imagesc(app.ImageAxes,im,"HitTest","off");
% or
im = imread(imgName)
im.HitTest = "off";
In looking into this, I found the following posts helpful.
  1 commentaire
Salad Box
Salad Box le 22 Nov 2021
Thank you so much! That's really helpful!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by