An axes' "ButtonDownFcn" callback is only executed when you click on the axis itself, not the objects in the axis. The "ButtonDownFcn" callback for the child objects will be executed instead.
If you want the axes' "ButtonDownFcn" callback function to be executed regardless of where you click in the axes, try the following:
1. Set the "HitTest" property for the axis' child objects to 'off'. The "HitTest" property determines whether the object can become the current object when it is clicked on. If the "HitTest" property is set to 'off', then the object below it will become the current object, which could be another of the axes' child objects or the axes itself. If all of the axes' child objects have their "HitTest" property set to 'off', then the axes will become the current object and its "ButtonDownFcn" callback will be executed.
2. 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.
set(gcf,'WindowButtonDownFcn','disp(''axis callback'')')
3. Define the "ButtonDownFcn" callbacks for the axes' child objects, so they have the same effect as calling the axes' "ButtonDownFcn" callback. This may include determining the object's Parent (the axes), and passing its handle as an input instead of the object's handle.
set(h,'ButtonDownFcn','disp(''axis callback'')')
Best Answer