Adding a contextmenu to an axes that mimics pan/zoom/rotate's contextmenu behavior

2 views (last 30 days)
Hi, I'm trying to implement a customized UIcontextMenu
hFigure = figure;
currentAxes = axes;
hline = plot(currentAxes,1:10);
props_context.Parent = hFigure;
props_context.Tag = 'myContextMenu';
currentAxes.UIContextMenu = uicontextmenu(props_context);
hui = currentAxes.UIContextMenu;
props = [];
props.Label = 'Test';
props.Tag = 'Test';
props.Separator = 'off';
props.Callback = @foo;
ufullview = uimenu(hui,props);
So far so good. But notice that I'm not able to right click on the line in the axes and have the contextmenu popping up.
I know one way to work around this would be to turn the line's hittest or pickablepart 'off', however if I do that
hline.HitTest = 'off';
Now if I enable the data cursor mode, note that it won't work because I just turned the HitTest to 'off'.
So my question goes...is there a way to add a context menu that works just like the pan/zoom/rotate mode's context menu? Note that they work regardless where you click within the axes.
Thanks

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!