Re: Contextual Menu doesn't respond to control+click
Re: Contextual Menu doesn't respond to control+click
- Subject: Re: Contextual Menu doesn't respond to control+click
- From: PGM <email@hidden>
- Date: Mon, 28 Aug 2006 21:31:36 -0400
On 28-Aug-06, at 14:41 PM, Nick Kreeger wrote:
Since you are building your menu in |rightMouseDown:|, you will
need to do
the same with |keyDown:| to trap a control-click.
That does not work as keyDown: does not fire when only the control
key is pressed. Likewise, checking for modifiers in mouseDown: also
does not work as mouseDown: does not get called on a control-click.
What I do to get similar behaviour from my tableView is to connect
the menu to the tableView in interface-builder as usual and then
override -(NSMenu *)menuForEvent:(NSEvent *)theEvent in my tableView
subclass with the code where I extend the selection. I by the way
first check whether the user has any columns selected so that I do
not unexpectedly change from column to row selection:
-(NSMenu *)menuForEvent:(NSEvent *)theEvent
{
if([[self selectedColumnIndexes] count] == 0){
//here do the stuff with row selection
}
}
Best Patrick
On 8/24/06, Brian Amerige <email@hidden> wrote:
Hi all,
I've got a contextual menu which works perfectly in my NSTableView,
with the exception of the fact that it doesn't respond to control
+clicks, but works fine with right clicks. I've got the following in
my NSTableView subclass:
- (void)rightMouseDown:(NSEvent *)theEvent
{
NSPoint p = [super convertPoint:[theEvent locationInWindow]
fromView:nil];
int i = [super rowAtPoint:p];
if (i < [super numberOfRows])
[super selectRowIndexes:[NSIndexSet
indexSetWithIndex:i]
byExtendingSelection:NO];
[NSMenu popUpContextMenu:[super menu] withEvent:theEvent
forView:self];
}
Thanks in advance!
Brian Amerige.
_______________________________________________
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden