I create a NSPopover programmatically like this:
popViewController *controller = [[popViewController alloc] initWithNibName:@"popViewController" bundle:nil];
NSPopover *thePopover = [[NSPopover alloc] init];
[thePopover setBehavior:NSPopoverBehaviorTransient];
[thePopover setAnimates:YES];
[thePopover setContentViewController:controller];
[thePopover showRelativeToRect: [[sender superview] bounds] ofView:[sender superview] preferredEdge:NSMaxXEdge];
When the function that has this code, is called, the NSPopover appears, but when i click somewhere on the screen, even inside the NSPopover, it closes and i get this error message in the console:
customMenuItem[8530] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1998
Jul 23 14:55:46 ThousandSunny.local customMenuItem[8530] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Jul 23 14:55:46 ThousandSunny.local customMenuItem[8530] <Error>: kCGErrorIllegalArgument: CGSRemoveWindowFromWindowMovementGroup: Invalid window
What is going wrong?