关于macos:Mac Cocoa App – Objective-C – 不同NSViewController中的不同Main menu | 珊瑚贝

Mac Cocoa App – Objective-C – Different Main menu in different NSViewController


我在我的应用程序中设置了一个主菜单。它有 App、Edit、View 和 Window 菜单。这就是我在主 NSViewController 中需要的。

但是用户可以打开另一个 NSViewController,我想在此 NSViewController 处于活动状态时将一些菜单项添加到编辑菜单。

实现这一目标的标准是什么?

  • 将所有菜单项放在主菜单中,并禁用或隐藏您不想要的菜单项。
  • 我试过了,但是我打开的窗口是模态的,它没有执行正确的操作。
  • 从用户体验 (UX) 的angular来看,以用户无法立即看到的方式隐藏和显示功能通常不是一个好主意。我的建议是始终将所有菜单项都包含在菜单中,并禁用特定用途不需要的菜单项。


可以使用NSMenuDelegate方法如

1
(void)menuNeedsUpdate:(NSMenu*)menu;

在此方法中,您可以根据特定条件添加/删除或启用/禁用特定项目。


来源:https://www.codenong.com/41564021/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9078.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?