Not being able to edit NSTextField on NSPopover even though Editable behavior is set

前端 未结 8 1408
别跟我提以往
别跟我提以往 2020-11-27 17:19

I have an application, which open popover with NSTextField. The text field is not editable. Behavior for text field is set to Editable. I still can

8条回答
  •  半阙折子戏
    2020-11-27 17:32

    I struggled with this for a while as well, until I realized it was a bug.

    However, instead of relying on an isActive state of a NSStatusItem view, I find it much more reliable to use the isShown property of the NSPopover you have implemented.

    In my code, I have a NSPopover in a NSViewController:

      - (BOOL)canBecomeKeyWindow
        {
            if([self class]==NSClassFromString(@"NSStatusBarWindow"))
            {
                NSPopover *mainPopover = [[((AppDelegate*)[NSApp delegate]) mainViewController] mainPopover];
                if(![mainPopover isShown])
                    return NO;
            }
    
            return YES;
        }
    

提交回复
热议问题