Cannot seem to setEnabled:NO on NSMenuItem

后端 未结 8 1464
故里飘歌
故里飘歌 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:18

    Had the same issue, so I thought I'd post my solution. NSMenu auto enables NSMenuButtons, so we have to override that.

    In IB:

    You should uncheck

    Or programmatically:

    // Disable auto enable
    [myMenu setAutoenablesItems:NO];
    
    // Test it
    [myMenuButton setEnabled:NO];
    [myMenuButton setEnabled:YES];
    

提交回复
热议问题