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

15 ビュー (過去 30 日間)
CJ
CJ 2015 年 9 月 30 日
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

回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by