ButtonDownFcn on children of UIFigure

5 次查看(过去 30 天)
I'm trying to trigger the ButtonDownFcn of a UIFigure when clicking on a child axes. In the below answer it was written that clicking on a child of the UIFigure would also trigger the callback, but this seems not to be true...
Steps to reproduce the problem:
-Create a new blank app
-Pull one axes onto the figure
-Add a callback for ButtonDownFcn of the UIFigure
-Add a breakpoint in that callback
-Click on the axes ---->> Nothing happens!
  1 个评论
Paul Shoemaker
Paul Shoemaker 2019-12-3
You might need to toggle the hittest property of the children objects "off." For the above example with the axes in the figure, you would get the handle for the axes (possibly with gca command) and set hittest off.
set(gca,'hittest','off'); % Or replace gca with the axes you want
I think that'll make it work.
Paul Shoemaker
MatlabInvesting.com

请先登录,再进行评论。

采纳的回答

Chidvi Modala
Chidvi Modala 2020-1-2
From my understanding, you are trying to add a callback for ButtonDownFcnof the UIFigure to trigger the callback, when clicking on child axes. From the link that you have referenced, your requirement can be achieved by using WindowButtonDownFcn callback and not ButtonDownFcn. ButtonDownFcn callback is triggered when user clicks a blank area of the UI Figure
WindowButtonDownFcn callback executes when the user clicks:
  • A blank area of the UI figure
  • A UI component within the UI figure that supports the ButtonDownFcn property
  • A graphics object within the UI figure that supports the ButtonDownFcn property
You can find WindowButtonDownFcn callback in the window section of UI Figure callbacks.
For more information on different callbacks, you can refer to Common callbacks, Keyboard Callbacks, Window Callbacks section here

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by