Cannot seem to setEnabled:NO on NSMenuItem

2020-06-30 07:15发布

I have subclassed NSMenu and connected a bunch of NSMenuItem's via Interface Builder. I have tested via the debugger to see that they really get initialized.

The menu is set to not auto enable items. Still when I set any of my NSMenuItem's to [myMenuItem setEnabled:NO] they continue to be enabled. Even if I call [self update] from within the NSMenu subclass.

What am I missing?

8条回答
\"骚年 ilove
2楼-- · 2020-06-30 07:47

Try calling [myMenuItem setEnabled:NO] from a different place and making sure that it happens after the menu-containing nib is loaded. Maybe do it right in the subclassed NSMenu's awakeFromNib.

查看更多
孤傲高冷的网名
3楼-- · 2020-06-30 07:50

enter image description here

You should uncheck Auto Enables Items on the closest parent NSMenu

查看更多
登录 后发表回答