Turning HitTest off for imrect

6 ビュー (過去 30 日間)
Stephen
Stephen 2014 年 7 月 15 日
回答済み: Brian 2023 年 1 月 16 日
I have been trying to turn the HitTest property off for an imrect object, such that I can click on objects behind it. However, a simple "set(imrectHan,'HitTest','off');" does not do the trick. Does anyone know how to solve this?

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 7 月 15 日
編集済み: Sean de Wolski 2014 年 7 月 15 日
The imrect is built from low-level lines and patches so turn the imrect's Children's 'HitTest' off.
h = imrect
set(get(h,'Children'),'HitTest','off')
  2 件のコメント
Ben11
Ben11 2014 年 7 月 15 日
That's good to know Sean thanks!
Stephen
Stephen 2014 年 7 月 15 日
Thank you, that worked very well!

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

その他の回答 (2 件)

Ben11
Ben11 2014 年 7 月 15 日
編集済み: Ben11 2014 年 7 月 15 日
What if you inverse the order of Children in your axes? Basically you would send the rectangle at the "back" of the current axis so you could play around with other elements. When you're done you can switch back. It might not be perfect but I think it would work; from the Matlab doc imrect does not have a HitTest property so maybe that's why using it does not work.
Example code to flip the order of the axes children:
set(gca,'children',flipud(get(gca,'children')))
Thanks to Matt Fig who provided the idea here
I tried with a simple code and 2 rectangles and it worked well.
  4 件のコメント
Stephen
Stephen 2014 年 7 月 15 日
Very happy to have the help! Any suggestions are mana when stuck
Ben11
Ben11 2014 年 7 月 15 日
Yep! I learned something with Sean's answer ; I did not know the trick to get the Children of imrect that's nice.

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


Brian
Brian 2023 年 1 月 16 日
NOTE: I created an image in a UIAxes using imagesc:
app.My_image_handle = imagesc(app.UWBAxes, app.UWBdata);
In that case I do NOT set the HitTest property of children of the image handle. Rather I set it directly on the image handle:
set(app.My_image_handle,'HitTest','off')

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by