Hi Nathan,

By overriding -keyDown: and not calling [super keyDown:keyEvent], you have stopped your view from actually processing the keys any further. That's why you aren't getting to either of the delete methods.

Hope this helps,
        - Greg

On Jul 7, 2008, at 4:59 PM, Nathan Vander Wilt wrote:

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.

Thanks, I forgot to mention that I tried overriding some of those action methods. However, I couldn't get them to fire.

If I implement:

- (BOOL)acceptsFirstResponder {
        return YES;
}

- (void)keyDown:(NSEvent*)keyEvent {
        (void)keyEvent;
        printf("key event received\n");
}

- (void)deleteBackward:(id)sender {
        (void)sender;
        printf("delete backward received\n");
}

- (void)deleteForward:(id)sender {
        (void)sender;
        printf("delete forward received\n");
}


...and then press delete or forward-delete, I only ever get "key event received". According to the chart at http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_3.html#/ /apple_ref/doc/uid/10000060i-CH3-SW10, it looks like the event should flow all the way down to the "Key Action?" conditional, and since it's a bound key binding I thought I should get the "Yes: Send action message to first responder" path.

However, on further investigation, I see that this is just a "potential" path diagram, and seems to be an example for if the first responder view is a text one, which mine will rarely be. Under what circumstances will the Cocoa Text Bindings system convert keypresses to the "text" actions, so that a non-NSResponder (ie, a window/app delegate) can perform the action?

thanks,
-natevw
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/greg%40omnigroup.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to