MATLAB: Assigning a context menu to a UIAxes

app designerMATLABuiaxes

I am using appdesigner with Matlab 2020b.
I have a UIAxes in the main window, and I would like to assign a context menu to that axis.
I have implemented the context menu, and I can attach it to the 'panel' that contains the UIAxes. The axis functions correctly when I right-click on the panel around the UIAxes.
But I cannot attach the context menu to the UIAxes itself. The menu only appears when I right-click on the panel, not on the UIAxes.
The context menu is assigned to the UIAxes (see attached PNG file).
Brian Wandell
wandell@stanford.edu
(lmperry@stanford.edu is the name of my lab manager. I would appreciate if you could make sure the message is also sent to my account).

Best Answer

Hello Brian,
You can attach Context Menu component to the UIAxes component by drag & drop, from the Component Browser, or from the Context Menus (if it's already made).
If you're creating menus programmatically, then you can assign them to UIAxes by ContextMenu property.