ButtonDownFunction on an image in App Designer

25 ビュー (過去 30 日間)
Salad Box
Salad Box 2021 年 11 月 18 日
コメント済み: Salad Box 2021 年 11 月 22 日
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.
  1 件のコメント
Salad Box
Salad Box 2021 年 11 月 22 日
Thank you so much! That's really helpful!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop 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