Handling keypresses in an NSTableView subclass
Handling keypresses in an NSTableView subclass
- Subject: Handling keypresses in an NSTableView subclass
- From: "Sean McBride" <email@hidden>
- Date: Tue, 17 May 2005 10:58:30 -0400
- Organization: Rogue Research
Hi all,
The NSTableView class handles several keypresses 'for free': page up,
page down, arrow keys, etc. Sadly, it does not handle others: home, end,
delete, del, clear, and probably others.
I'm having trouble supporting all these keys 'nicely'.
For sure I am going to have to subclass and override keyDown:, but how
exactly?
NSResponder's interpretKeyEvents: looks promising, so I tried this:
- (void)keyDown:(NSEvent*)event
{
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
}
- (void)deleteBackward:(id)sender
{
...
}
- (void)deleteForward:(id)sender
{
...
}
And now delete and del (though not clear) work! I like this solution,
because it should work with any custom keybindings the user has.
HOWEVER, now the arrow keys stop working, and just cause beeps. Adding a
[super keyDown:event] gets the arrow keys working again, but the beeps
are still there. And to complicate things further, NSResponder does not
seem to have an action method corresponding to the home and end keys (ie
there is no scrollToBeginningOfDocument:).
So how can I handle the keys Apple neglected to support, while still
supporting arbitrary keybindings?
Thanks!
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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