ButtonDownFcn on children of UIFigure

4 visualizaciones (últimos 30 días)
Paco Langjahr
Paco Langjahr el 28 de Nov. de 2019
Comentada: Paco Langjahr el 7 de En. de 2020
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 comentario
Paul Shoemaker
Paul Shoemaker el 3 de Dic. de 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

Iniciar sesión para comentar.

Respuesta aceptada

Chidvi Modala
Chidvi Modala el 2 de En. de 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
  1 comentario
Paco Langjahr
Paco Langjahr el 7 de En. de 2020
Thank you very much for this clear and simple answer!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by