Re: Double-click/Return/Enter in NSTableView
Re: Double-click/Return/Enter in NSTableView
- Subject: Re: Double-click/Return/Enter in NSTableView
- From: Brian Stern <email@hidden>
- Date: Fri, 2 Jun 2006 14:54:27 -0400
At 10:28 AM -0700 6/2/06, James Bucanek wrote:
>I have an NSTableView displaying a list of records. I want the user to be
>able to edit a record in a separate window by double-clicking on a row or
>selecting one or more rows and pressing Return or Enter.
[myTable setDoubleAction:@selector(handleDoubleClick:)];
> Also, the should be able to delete a record by selecting it and using
>Edit > Clear or the Delete key.
- (void)keyDown:(NSEvent *)event
{
unichar u = [[event charactersIgnoringModifiers]
characterAtIndex: 0];
if (u == NSDeleteCharacter || // backwardDelete
u == NSDeleteFunctionKey) // forwardDelete
{
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
}
else
{
[super keyDown:event]; // all other keys
}
}
Simply adding this override will result in NSTableView calling the
deleteBackward: and deleteForward: action methods, which already exist, so
you don't need to do anything else besides adding the keyDown override
shown above.
--
Brian Stern
email@hidden
_______________________________________________
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