Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix for TTTextEditor doubling first newline #464

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
Contributor

vguerci commented Mar 10, 2011

I can't believe that this fix is so simple and that bug hanging around for years...
I suspect this \n addition to be there for one strange reason.
Then I would recommend more testing, but that does fix the TTCatalog table control item sample.
Related bugtracker issue : #317

I can't test this fix right now, but I'm pretty confident that the issue is much more subtle than just removing the additional \n. Have you tested this change to make sure that the view reliably swaps between the UITextView and UITextField subclasses?

Contributor

vguerci commented Mar 10, 2011

I tested this on TTCatalog sample in table control items view.
This code is only called once when UITextfield swapped by TTTextview.

Contributor

jwang commented Mar 23, 2011

this does need more testing. :)

I don't agree with the vguerci's fix. It doesn't work when the first typed char is new line. It looks like the problem here is that textFieldShouldReturn method is called before the new line char is passed to first responder and UITextView receives it when it is reassigned in the same method - so the new line becomes doubled.

I think better solution is to return NO in textFieldShouldReturn method, so the new line char will not be passed to first responder. Also I think that will be better if UITextView and UITextField are swapped not when Return is pressed but after first char is typed in UITextField, and swapped back when user delete all chars. This will fix also the issue when user changes cursor position in the middle of typed text and press Return.

I agree with intruder. Returning no in textFieldShouldReturnMethod helped me in solving this issue.

diff --git a/src/Three20UI/Sources/TTTextEditorInternal.m b/src/Three20UI/Sources/TTTextEditorInternal.m
index 2db4ce9..afbf6b8 100644
--- a/src/Three20UI/Sources/TTTextEditorInternal.m
+++ b/src/Three20UI/Sources/TTTextEditorInternal.m
@@ -216,6 +216,7 @@ TT_FIX_CATEGORY_BUG(TTTextEditorInternal)
}

[_textEditor performSelector:@selector(didChangeText:) withObject:(id)YES];
return NO; //Added this line

if ([_delegate respondsToSelector:@selector(textEditorDidChange:)]) {
[_delegate textEditorDidChange:_textEditor];

Contributor

jamesgpearce commented Nov 18, 2013

Facebook has not maintained or supported Three20 for some time, and we are closing its old and outstanding pull requests.

Many, many thanks for your support of the project. If you have any further questions, please don't hesitate to let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment