ButtonDownFunction on an image in App Designer

38 visualizaciones (últimos 30 días)
Salad Box
Salad Box el 18 de Nov. de 2021
Comentada: Salad Box el 22 de Nov. de 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?

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 19 de Nov. de 2021
Editada: Cris LaPierre el 19 de Nov. de 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.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by