Re: Delete action from variety of key presses
Re: Delete action from variety of key presses
- Subject: Re: Delete action from variety of key presses
- From: Ken Thomases <email@hidden>
- Date: Mon, 7 Jul 2008 18:20:56 -0500
On Jul 7, 2008, at 5:29 PM, Nathan Vander Wilt wrote:
I want to be able to delete the items selected in a view, but am
struggling finding a best way to turn the different key presses
into a -delete: action that my controller can handle. I think I
want (it seems expected functionality anyway) the delete key, the
forward delete key, as well as Cmd-Delete to all trigger this action.
The Cocoa Text Bindings system already translates keys and key
combinations into invocations of NSResponder methods. <http://
developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/
TextDefaultsBindings/chapter_9_section_1.html>
So, what you need to do is determine which methods those keys are
already mapping to, override those methods in the appropriate place
in your responder chain (e.g. on your custom view or application
delegate), and have them all invoke some common method to do what you
want.
Here's a (somewhat dated) third-party page describing the text-
binding system: <http://www.hcs.harvard.edu/~jrus/Site/Cocoa Text%
20System.html>.
And here's that guy's list of the default bindings, which has a few
minor inaccuracies but should be mostly useful: <http://
www.hcs.harvard.edu/~jrus/Site/system-bindings.html>.
The definitive list can be found by interpreting /System/Library/
Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict, but
the use of non-printable characters can make interpreting that file
somewhat difficult.
Cheers,
Ken
_______________________________________________
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