NSTextView的右键菜单如何隐藏不想用的item?
作者:
开发者老岳 | 来源:发表于
2017-09-26 11:17 被阅读0次- (NSMenu *)textView:(NSTextView *)view menu:(NSMenu *)menu forEvent:(NSEvent *)event atIndex:(NSUInteger)charIndex
{
[menu.itemArray enumerateObjectsUsingBlock:^(NSMenuItem *menuitem, NSUInteger idx, BOOL *stop1) {
if (menuitem.action == @selector(submenuAction:)) {
[menuitem.submenu.itemArray enumerateObjectsUsingBlock:^(NSMenuItem *subMenuItem, NSUInteger idx, BOOL *stop2) {
//去掉字体、布局方向
if (subMenuItem.action == @selector(orderFrontFontPanel:) || subMenuItem.action == @selector(changeLayoutOrientation:)) {
menuitem.hidden = YES;
*stop2 = YES;
}
}];
}
}];
return menu;
}
本文标题:NSTextView的右键菜单如何隐藏不想用的item?
本文链接:https://www.haomeiwen.com/subject/ighsextx.html
网友评论