Cannot seem to setEnabled:NO on NSMenuItem

后端 未结 8 1368
故里飘歌
故里飘歌 2021-02-12 10:51

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 initi

相关标签:
8条回答
  • 2021-02-12 11:24

    I solved it with the help of a colleague, so I post it here for others that experience the same issue.

    You should set your NSMenu-sublass to auto-enable items (default behaviour) and then implement this method in the NSMenu-sublass.

    - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
        return [menuItem isEnabled];
    }
    
    0 讨论(0)
  • 2021-02-12 11:27

    You should uncheck Auto Enables Items on the closest parent NSMenu

    0 讨论(0)
提交回复
热议问题