CPTextField Changes

16 views
Skip to first unread message

Ross Boucher

unread,
Oct 28, 2009, 11:24:17 PM10/28/09
to objecti...@googlegroups.com
In an attempt to make it work more like NSTextField, I've gone ahead
and changed several things about CPTextField.

First, didbegin and didend editing are now related to whether or not
the text content has actually changed. If you don't type anything, you
won't get a didBeginEditing (though you may still get a didEndEditing
sometimes).

didEndEditing is also sent when enter is pressed, which essentially
commits the edit. And I've added support for sendsActionOnEndEditing,
so you can have your textfield send its action only on return, or
whenever editing ends.

Finally, in recognition of the fact that these changes break a lot of
what people are using begin/end for, I've added new notifications for
focus/blur which you can listen to. That should give an appropriate
hook without the need to subclass for what most people need.

Let me know if I've broken anything, or if you see a potential problem.

Thanks,
Ross

Saikat Chakrabarti

unread,
Oct 29, 2009, 6:44:03 PM10/29/09
to objecti...@googlegroups.com
Thanks for this! Definitely makes CPTextField a bit easier to work
with. One question though:

> First, didbegin and didend editing are now related to whether or not
> the text content has actually changed. If you don't type anything, you
> won't get a didBeginEditing (though you may still get a didEndEditing
> sometimes).

In what cases does it send didEndEditing? It seems like right now, it
doesn't hit textDidEndEditing unless the text field value is first
edited, and in the code, I see, in CPTextFieldKeyPressFunction:

if (owner._isEditing)
{
owner._isEditing = NO;
[owner textDidEndEditing:[CPNotification
notificationWithName:CPControlTextDidEndEditingNotification
object:owner userInfo:nil]];
}

I see the same in resignFirstResponder. This makes it seem like
textDidEndEditing will only be called if the user has started editing
the text field first? Is that the expected behavior? Or am I missing
something?

Thanks,
Saikat
Reply all
Reply to author
Forward
0 new messages