Re: Control-Click vs Right-Click in NSTableView
Re: Control-Click vs Right-Click in NSTableView
- Subject: Re: Control-Click vs Right-Click in NSTableView
- From: Randall Meadows <email@hidden>
- Date: Wed, 20 Aug 2008 16:21:38 -0600
On Aug 20, 2008, at 4:02 PM, Matthew Mashyna wrote:
I have an NSTableView subclass whose only override method is
rightMouseDown. I override it so I can have it select the table row
before validating and presenting the context menu (by then passing
it up to [super rightMouseDown]).
This works nicely but I have found that it does not work for control
clicks. For a another view item I overrode mouseDown to check for
the control key and call [self rightMouseDown] if needed.
For NSTableView I can catch rightMouseDown but I can't seem to catch
mouseDown. When I control click a row the context men comes up over
a non-selected item which, ironically enough, gives me an out-of-
context menu.
How can I get control clicks on my NSTableView ?
Wow, I *just* did this yesterday. Well, something very close,
anyway. The solution I went with was implementing menuForEvent in my
table view subclass, and using
int row = [self rowAtPoint:[self convertPoint:[event locationInWindow]
fromView:nil]];
to figure out which row the click was on, and then force that row to
be selected (in my case, the menu was coming up for a row that was not
selected, and if there was no row selected at all in the menu, the
following logic barfed).
At the end, I just return [self menu], returning the menu that was
already wired up in the nib.
HTH.
randy
_______________________________________________
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