Re: Consistent Contextual Menu in NSTableview
Re: Consistent Contextual Menu in NSTableview
- Subject: Re: Consistent Contextual Menu in NSTableview
- From: Nate Weaver <email@hidden>
- Date: Mon, 21 Apr 2008 15:37:09 -0500
I would probably override -menuForEvent: instead of -rightMouseDown: .
Leopard also has a bit nicer contextual menu handing for table/outline
views: If you right-click a row that's not currently selected it
highlights just an outline and doesn't change the selection (you can
use -clickedRow to get that row from within your action method(s)).
On Apr 21, 2008, at 11:59 AM, Steve Cronin wrote:
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden