您需要做的第一件事是将
root object的
ShowHiddenHandles property设置为“on”,这将使隐藏的句柄可被发现.然后你可以做以下事情:
>> hMenu = get(lg, 'UIContextMenu') % Get the context menu handle
hMenu =
ContextMenu with properties:
Callback: ''
Children: [12×1 Menu] % This would be empty if handles were still hidden
Show all properties
>> hItems = get(hMenu, 'Children') % Get the menu item handles
hItems =
12×1 Menu array:
Menu (scribe:legend:mcode)
Menu (scribe:legend:propedit)
Menu (scribe:legend:orientation)
Menu (scribe:legend:location)
Menu (scribe:legend:interpreter)
Menu (scribe:legend:font)
Menu (scribe:legend:linewidth)
Menu (scribe:legend:edgecolor)
Menu (scribe:legend:color)
Menu (scribe:legend:edittitle)
Menu (scribe:legend:delete)
Menu (scribe:legend:refresh)
>> delete(hItems(4)); % Delete the fourth item
以上也可以使用点符号进行属性访问,如下所示:
delete(lg.UIContextMenu.Children(4));
此外,您可以隐藏手柄并使用findall,这需要您了解您正在寻找的对象的一些属性.例如,要查找并删除当前图中“Label”属性设置为“Location”的菜单对象,请执行以下操作:
delete(findall(gcf, 'Label', 'Location'));
对于上述所有情况,您可以确认“位置”选项现在已从上下文菜单中消失: