ButtonDownFcn on children of UIFigure

8 views (last 30 days)
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 Comment
Paul Shoemaker
Paul Shoemaker on 3 Dec 2019
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

Sign in to comment.

Accepted Answer

Chidvi Modala
Chidvi Modala on 2 Jan 2020
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

More Answers (0)

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!