thermogl / TITokenField

An iOS version of the NSTokenField (See To: field in Mail and Messages).
http://thermoglobalnuclearwar.com/opensource/
599 stars 172 forks source link

Cannot use enablesReturnKeyAutomatically #22

Open hsoi opened 12 years ago

hsoi commented 12 years ago

I wish to use enablesReturnKeyAutomatically with my TITokenField.

Of course I can set it to YES, but it winds up not doing anything. My guess? the kTextEmpty and/or kTextHidden are not visible to the eye, but they are there and thus the text of the field is non-zero. And so, the field never is truly empty and so the Return key never disables.

I'd like to be able to use enablesReturnKeyAutomatically, but due to the hidden non-empty text, can't. :-(

thermogl commented 12 years ago

Yeah that's the problem - we have to do this to get a notification when the delete key is pressed, otherwise shouldChangeCharactersInRange isn't called when there are only tokens and no text.

We might be able to pretend to empty, depending on how the keyboard determines the field is empty, though.

hsoi commented 12 years ago

Yeah, it looked like the way to fake out the UITextField.

I did wonder how it determines if the field is empty, but my guess is it looks right at the [[field text] length] > 0 or something simple and otherwise inaccessible like that. So I'm not sure what can be done in this avenue. :-(

thermogl commented 12 years ago

Dang! You know the method that asks the length to determine whether it's empty? Kinda just thinking out loud, but you never know.

hsoi commented 12 years ago

No, I don't know what it actually uses to determine state... I'm just guessing. I'm going to experiment tho because I'm in a situation blending a UISearchBar and a TITokenField (2 fields, both needed towards a Search). UISearchBar seems to ONLY use enablesReturnKeyAutomatically and is forced to YES and I can't find a way to disable it... but then TITokenField basically can't support it and it's always enabled... so this leaves me in a weird UI situation. :-( Seems my best chance for resolve is within TITokenField since at least that I have some code access to.

I'll hack at it more after the long weekend.