Hi Amos,
In my understanding, you have an array of custom UI components where these components are composed of standard UI objects. You want to determine the parent UI component of the standard UI object which is currently in focus. Also, the “ButtonDownFcn” callback is not being accessed universally.
To obtain the parent of a child object, the child object’s handle is fetched. The currently focused UI object’s handle can be temporarily disabled, doing this makes “uicontrol” point to the parent of the standard child object which was in focus then.
Please refer to the following MATLAB Answer’s thread where similar issues were resolved:
Please know that "ButtonDownFcn" callback is only executed when you click on the standard child component objects itself. If you want the "ButtonDownFcn" callback function to be executed regardless of where you click in the UI component, try the following:
- Set the "HitTest" property for the custom parent and children objects to 'off'. The "HitTest" property determines whether the object can become the current object when it is clicked on.
Please refer to the following MathWorks documentation link to learn more about “HitTest”:
- Specify the desired callback function as the figure's "WindowButtonDownFcn" property. The "WindowButtonDownFcn" callback is executed whenever you click in the figure and is executed before the "ButtonDownFcn" callback of any objects, including the figure itself.
You may refer to this MATLAB Answer’s thread for a similar discrepancy that a user had faced:
- Define the "ButtonDownFcn" callbacks for the child objects, so they have the same effect as calling the parent UI component’s "ButtonDownFcn" callback. This may include determining the object's Parent and passing its handle as an input instead of the object's handle.
Hope this helps!