Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

iPhone textField auto-correction bug

Creating a textField by doing something like this:

inline code

        var tf = Titanium.UI.createTextField({
                    top: fieldPosition,
                    left: fieldLeft,
                    height: fieldHeight,
                    width: fieldWidth,
                    borderStyle: fieldBorderStyle,
                    value: fields.fieldByName(fname)
                    });
        tf.addEventListener('change', mkSaver(tableName, fname, tf));

Where the Saver function stores the tf.value away. This work just fine.
—– HOWEVER ——
You have seen that when typing into a textfield, iPhone will suggest capitalization, or spelling changes, etc…
If the user accepts those auto-corrections, the textField changes on screen, but NO CHANGE EVENT is triggered.
In my case, this results in a difference between what's stored by the function, and what ends up appearing on the screen.
I have also tried storing on 'return', and the same will hold true. The screen shows the auto-capitalization or correction, but tf.value has all lower case, or whatever the user typed. Even if I allow the capitalization, and then hit return (catching the return event) after the correction was made.

Titanium 1.0 and mobile SDK 1.0
Macbook pro snow leopard
running on iPhone simulator

Regards,
Ron

— asked March 14th 2010 by Ron Burns
  • bug
  • iphone
  • textfield
0 Comments

5 Answers

  • I see similar behavior on the simulator and on device. If I type something into a textfield, then edit that textfield, the "value" property doesn't seem to match what's displayed on-screen.

    This happens with autocorrect disabled and enabled.

    — answered March 15th 2010 by Alan McConnell
    permalink
    0 Comments
  • Check Kitchen Sink they have an undocumented property autocapitalization in the textfields that controls this. I wish Appcelerator would properly maintain their documentation.

    Possible Values of the property:

    Ti.UI.TEXT_AUTOCAPITALIZATION_ALL
    Ti.UI.TEXT_AUTOCAPITALIZATION_NONE
    Ti.UI.TEXT_AUTOCAPITALIZATION_SENTENCES
    Ti.UI.TEXT_AUTOCAPITALIZATION_WORDS
    

    Example from Kitchen Sink:

    var username = Ti.UI.createTextField({
        autocapitalization:Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
        width:300,
        top:10,
        height: 35,
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
        hintText:'Username'
    });
    win.add(username);
    var password = Ti.UI.createTextField({
        autocapitalization:Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
        width:300,
        top:55,
        height:35,
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
        passwordMask:true,
        hintText:'Password'
    });
    
    — answered February 9th 2011 by Audra M. King
    permalink
    2 Comments
    • If my testing is valid, the above-named constants function inconsistently if at all. The documentation states:

      autocapitalization: boolean, boolean to indicate if the text in the field should be autocapitalized as typed.

      This definition was lifted from the Searchbar api.
      So, auto-cap shouldn't get a constant passed at all, but a boolean true/false. I tried that. I didn't work in a normal text field. Nonetheless, the constants work on some of my fields, say for example, suppressing auto-cap on the email field. But not on others, like when I want to init-cap first and last names. I see no rhyme or reason on how to get these constants to operate correctly. It's such a pain in the ass, but I need this functionality. If anyone understands how to consistently implement these constants, I'd love to hear it.

      — commented September 9th 2011 by Michael Stelly
    • I just learned that these constants do not work if something OTHER than the default keyboard is used.

      — commented September 9th 2011 by Michael Stelly
  • i have exactly the same behaviour and not just the missing change event, with no event handling the value has not changed

    — answered March 17th 2010 by Dan Mullineux
    permalink
    0 Comments
  • I believe Nolan has entered a bug report for this issue.

    Ron

    — answered March 17th 2010 by Ron Burns
    permalink
    0 Comments
  • i prefer to save the data with the "blur" event.

    — answered July 3rd 2011 by Juan Carlos Salinas Ojeda
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.