Weird issue with NSMenuItem, custom view and mouseUp:

前端 未结 1 1066
隐瞒了意图╮
隐瞒了意图╮ 2021-02-15 06:46

I\'m having a very very strange issue here with a NSMenu.

About half the NSMenuItems I use have custom views on them through the setView: method on NSMenuItem. In this c

相关标签:
1条回答
  • 2021-02-15 07:10

    I had the same problem. Turns out the issue was I was launching an external application after the first menu click, and when the menu was opened again its window was no longer key. Adding this method to the NSView subclass I'n using inside the menu items fixed the problem:

    - (void)viewWillMoveToWindow:(NSWindow *)newWindow;
    {
        [super viewWillMoveToWindow:newWindow];
    
        if ( newWindow != nil && ![newWindow isKeyWindow] )
            [newWindow becomeKeyWindow];
    
        [self updateTrackingAreas];
    }
    

    For more context, have a look at this link: http://openradar.appspot.com/7128269

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