Re: Contextual menus in a NSTableView
Re: Contextual menus in a NSTableView
- Subject: Re: Contextual menus in a NSTableView
- From: Richard Schreyer <email@hidden>
- Date: Thu, 20 Dec 2001 18:44:33 -0800
On Thursday, December 20, 2001, at 09:02 AM, Stiphane Sudre wrote:
Is it not problematic that when you control click on a line, this line
is not selected ?
I've just discovered this little inconsistency between the traditional
Mac OS behavior (which can be seen in the Finder in Icon mode since the
list mode is buggy) and this behavior.
In fact, I'm sure it's a more complex topic since it depends on whether
you consider the contextual menu to be the one of the selected row(s)
or the one of the TableView.
I can't stand Cocoa's default behavior. I fixed it by inserting the
following in a subclass of NSTableView
- (void)rightMouseDown:(NSEvent *)theEvent {
NSPoint point = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
int row = [self rowAtPoint:point];
[self selectRow:row byExtendingSelection:NO];
[super rightMouseDown:theEvent];
}
This selects the correct row when the user right clicks, although I just
noticed it doesn't work when the user control-clicks. Something else
for the bug list...
Richard Schreyer