Re: updating NSTextField with key validation?
Re: updating NSTextField with key validation?
- Subject: Re: updating NSTextField with key validation?
- From: Sidney San Martín <email@hidden>
- Date: Wed, 15 Apr 2009 21:58:53 -0400
I'm writing this from my iPhone so method names may be off, but it
might be worth trying willChangeValueForKey and didChangeValueForKey
from your validation code if you need to update the text field's value
without changing focus.
Also, if I recall correctly, the docs state that you should never use
resignFirstResponder directly. I know it's a temporary solution, but
you should be aware of it.
On Wednesday, April 15, 2009, David Scheidt <email@hidden> wrote:
>
> On Apr 14, 2009, at 12:02 PM, David Scheidt wrote:
>
>
>
> On Apr 14, 2009, at 11:54 AM, Kyle Sluder wrote:
>
>
> You want to make the text field "continuous". Be aware that this will
> also cause your changes to be committed, not just validated,
> continuously.
>
>
> Do you mean the checkbox in IB labelled "continuously updates value"? That's checked, and my validation methods are called after each keystroke. It's just that the UI isn't updated until the textfield is no longer the first responder._______________________________________________
>
>
> So. I implemented a delegate with a controlTextDidChange:(NSNotification *)aNotification
> method. This gets called after each keystroke, as I'd expect. If I do
>
> NSTextField * myObject = [aNotification object];
> [myObject resignFirstResponder];
> [myObject becomeFirstResponder];
>
> in the delegate method, the coerced string in the TextField is displayed properly. Of course, I'm *sure* this is the Wrong Way To Do Things, if only because when the TextField becomes firstResponder again, it selects all the text in the text, and it gets deleted when you type the next character. I'm clearly missing something here. Anybody know what that might be?_______________________________________________
>
> 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
>
_______________________________________________
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