3

I've developed for Mac before but this is the first time I've attempted to use the NSPopover control, which seemed like a great idea to start out with but so far is causing me no end of problems. The applciation is a menu bar application. I have two NSButton objects in the NSPopover's view controller, the NSPopover is being created programmatically in another subclass of NSButton, the same button which it is being shown relative to. This NSButton that it is being shown relative to is contained along with some other buttons in an NSMenuItem

The popup, containing the two buttons, is being shown fine (see screenshot below), however, despite the 'Yes' button being highlighted with a focus ring, neither button responds to click events, they do not even graphically click in like I would expect them to.

enter image description here

And this is the code that creates the NSPopover and positions it onscreen:

someViewController *confirmationDialogue = [[someViewController alloc] initWithNibName:@"someViewController" bundle:nil];

popOver = [[NSPopover alloc] init];
[popOver setBehavior:NSPopoverAppearanceMinimal];
[popOver setBehavior:NSPopoverBehaviorTransient];
[popOver setContentViewController:confirmationDialogue];
[popOver showRelativeToRect:NSMakeRect(0, 0, self.frame.size.width, self.frame.size.height))
                     ofView:self
              preferredEdge:NSMaxYEdge];

Has anyone got any kind of solution/workaround to this?

Thanks in advance :)

P.s. This is my first question on SO, so I hope I've provided enough information but I'll give any more details as needed.

koen
  • 5,383
  • 7
  • 50
  • 89
AlexJHayward
  • 53
  • 1
  • 5
  • 1
    Can you provide more details about the app design? You mention it's from an NSMenuItem, so a popover is being shown from a menu? That's pretty non-standard and likely not implicitly supported. – Taylor Jul 07 '14 at 03:57
  • @Taylor Yes, the popover is showing from a button that is held in an NSView, that in turn is set as the view of an NSMenuItem, which is showing from an NSMenu in the system menu bar. The Popover is then shown relative to this button when it is clicked. It is fairly non standard but I'm using the same technique to show another popover that contains an NSTextField and the text field functions exactly as expected so I assumed that the buttons would too. – AlexJHayward Jul 09 '14 at 09:57

0 Answers0