Skip navigation.
 
mlConsistent Contextual Menu in NSTableview
FROM : Steve Cronin
DATE : Mon Apr 21 18:59:13 2008

Folks;

I'm having some difficulty getting consistent contextual menu behavior 
in NSTableView.

In the Finder and iTunes (what I feel most users are familiar with) if 
a row is selected but the user causes a contextual menu on a different 
row then row selection changes.
(I don't want to start a UI flame about 'correctness') I'm only 
interested in consistency!!

NOTE: the contextual menu can appear by a right mouse click, a two-
fingered tap, and a control-click which appear to be detected as 
different events (see below)

The base NSTableView class does NOT change the selection when a 
contextual click occurs on a row
If I sub-class and add:
- (void)rightMouseDown:(NSEvent *)theEvent {
   [self selectRow:[self rowAtPoint:[self convertPoint:[theEvent 
locationInWindow] fromView:nil]] byExtendingSelection:NO];
   [super rightMouseDown:theEvent];
}

I get half-way home.  Now the right mouse click and the two-fingered 
tap will alter the selection.

BUT

the control-click does not.

The Cocoa adage, "if you are working too hard, you probably are" keeps 
rummaging around my brain....

What is the preferred means to efficiently make consistent contextual 
menu behavior like Finder and iTunes?

Thanks,
Steve

Related mailsAuthorDate
mlConsistent Contextual Menu in NSTableview Steve Cronin Apr 21, 18:59
mlRe: Consistent Contextual Menu in NSTableview Nate Weaver Apr 21, 22:37
mlRe: Consistent Contextual Menu in NSTableview Corbin Dunn Apr 22, 17:51