On 27-Jun-09, at 16:26 , DKJ wrote:

I'm using this method:

textView:shouldChangeTextInRange:replacementText:

to let users put special symbols into a UITextView.

I detect the Return key by checking whether the input string is equal to @"\n". But how would I detect the back-delete key? @"\b" doesn't do it. And I can't seem to find any docs that list these codes.


I wanted to let the back-delete key do what it normally does, while at the same time stopping other keys like '1', '&', etc. from being processed. (i.e. The method returns 'NO' when those keys are pressed.)

I found (more or less by accident) that this will do the trick:

        if( [text length] == 0 )
                return YES;

where 'text' is the replacementText: parameter of the method.

I don't know why it works, but that's not important right now.

Thanks to anyone who's been thinking about this.

dkj
_______________________________________________

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 arch...@mail-archive.com

Reply via email to