Skip to content

Commit

Permalink
Allow popover to be dismissed
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Oct 1, 2023
1 parent 14baf92 commit 4c6b833
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Headers/AppKit/NSStoryboardSegue.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ APPKIT_EXPORT_CLASS
id _sourceController;
id _destinationController;
NSStoryboardSegueIdentifier _identifier;

NSString *_kind;
NSString *_relationship;
id _popoverAnchorView;
NSPopoverBehavior _popoverBehavior;
NSPopover *_popover;
NSRectEdge _preferredEdge;

GSStoryboardSeguePerformHandler _handler;
}

Expand Down
8 changes: 6 additions & 2 deletions Source/NSPopover.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,16 @@ - (void) close
{
[_realPanel close];
[_realPanel setDelegate:nil];
[_realPanel orderOut: nil];
_shown = NO;
}

- (IBAction) performClose: (id)sender
{
[_realPanel performClose:sender];
[_realPanel setDelegate:nil];
[_realPanel performClose: sender];
[_realPanel setDelegate: nil];
[_realPanel orderOut: nil];
_shown = NO;
}

- (void) showRelativeToRect: (NSRect)positioningRect
Expand Down
29 changes: 21 additions & 8 deletions Source/NSStoryboardSegue.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,27 @@ - (void) perform
}
else if ([_kind isEqualToString: @"popover"])
{
NSPopover *po = [[NSPopover alloc] init];
NSRect rect = [_popoverAnchorView frame];

[po setBehavior: _popoverBehavior];
[po setContentViewController: _destinationController];
[po showRelativeToRect: rect
ofView: _popoverAnchorView
preferredEdge: _preferredEdge];
if (_popover == nil)
{
NSPopover *po = [[NSPopover alloc] init];
NSRect rect = [_popoverAnchorView frame];

_popover = po; // weak... since we manually release...
[po setBehavior: _popoverBehavior];
[po setContentViewController: _destinationController];
[po showRelativeToRect: rect
ofView: _popoverAnchorView
preferredEdge: _preferredEdge];
}
else
{
if ([_popover behavior] == NSPopoverBehaviorTransient)
{
[_popover close];
RELEASE(_popover);
_popover = nil;
}
}
}
else if ([_kind isEqualToString: @"sheet"])
{
Expand Down

0 comments on commit 4c6b833

Please sign in to comment.