ButtonDownFunction on an image in App Designer

25 次查看(过去 30 天)
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?

采纳的回答

Cris LaPierre
Cris LaPierre 2021-11-19
编辑:Cris LaPierre 2021-11-19
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by