Skip to content

Commit

Permalink
Posts associated selection update messages associated with the LITabC…
Browse files Browse the repository at this point in the history
…ontrol prior to context menu display.
  • Loading branch information
monyschuk committed Nov 18, 2013
1 parent 67ab07a commit 1c652cd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions LITabControl/Classes/LITabCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,29 @@ - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *
NSPoint location = [controlView convertPoint:[theEvent locationInWindow] fromView:nil];

if (self.menu.itemArray.count > 0 && NSPointInRect(location, popupRect)) {

// this enclosingTabControl business is a bit hokey
// but it ensures that the receiver of context popup
// actions can determine which tab is associated with
// the action. It also ensures that the dataSource and
// target of the control updates associated views prior
// to context menu display...

id view = controlView;
LITabControl *enclosingControl = nil;
LITabControl *enclosingTabControl = nil;
while ((view = [view superview])) {
if ([view isKindOfClass:[LITabControl class]]) {
enclosingControl = view;
enclosingTabControl = view;
break;
}
}

[enclosingControl setSelectedItem:self.representedObject];
if (enclosingTabControl) {
[enclosingTabControl setSelectedItem:self.representedObject];
[NSApp sendAction:enclosingTabControl.action to:enclosingTabControl.target from:enclosingTabControl];
[[NSNotificationCenter defaultCenter] postNotificationName:LITabControlDidChangeSelectionNotification object:enclosingTabControl];
}

[self.menu popUpMenuPositioningItem:self.menu.itemArray[0] atLocation:NSMakePoint(NSMidX(popupRect), NSMaxY(popupRect)) inView:controlView];
return YES;

Expand Down

0 comments on commit 1c652cd

Please sign in to comment.