Author Topic: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput  (Read 12538 times)

ijneb11

  • Guest
Hi,

I got an annoying behaviour on my login/password feature I'm implementing with NGUI: the autocorrect is active.
As I don't want to ask my users to go turn it off in their phone settings, I'd like to know if there is a way to turn it off through NGUI.

Thanks
Benjamin

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #1 on: June 29, 2012, 05:24:59 AM »
The keyboard is shown on UIInput, line 200.

ijneb11

  • Guest
Thanks. As usual fast and clear :)

ijneb11

  • Guest
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #3 on: June 29, 2012, 08:18:22 AM »
Talking keyboard parameters, I checked all the possible options in the TouchScreenKeyboard.Open method and I don't seem to find how to disable the auto capitalization of the first letter you type.

Did I miss something? Does anyone have a tip for this?

(I know that this is more a Unity question than a NGUI one, but it fits so well in this thread  ;))

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #4 on: June 29, 2012, 08:38:33 AM »
I have no idea. :)

PhilipC

  • Guest
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #5 on: June 29, 2012, 10:43:04 AM »
Unity doesnt support all of the iOS open commands (not sure why). If you wish to have the ones that are missing you will have to write your own in obj-c then have NGUI use your open method instead of Unity's

ijneb11

  • Guest
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #6 on: June 29, 2012, 11:06:56 AM »
Thanks for the answers, even if it's bad news (bad as "not fast fix" news) :)

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #7 on: August 30, 2012, 11:51:55 AM »
Sorry to bump, but could I ask to get this boolean added to the text field in an upcoming release? I realize it is very easy to fix, but it is error prone as it keeps getting overwritten when I update my NGUI. Thanks!

PhilipC

  • Guest
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #8 on: August 30, 2012, 12:20:39 PM »
Post you change and we can see about working it in. Thanks.

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: [iOS/Android] How to deactivate keyboard's Autocorrect for UIInput
« Reply #9 on: August 30, 2012, 12:28:01 PM »
  1. (Around Line 73 UIInput.cs)
  2.         /// <summary>
  3.         /// Whether this input field should auto correct text or not.
  4.         /// </summary>
  5.         public bool autoCorrect = true;
  6.  

  1.                                
  2. (Around Line 200 UIInput.cs)
  3.                                  if (Application.platform == RuntimePlatform.IPhonePlayer ||
  4.                                         Application.platform == RuntimePlatform.Android)
  5.                                 {
  6. #if UNITY_3_4
  7.                                         mKeyboard = iPhoneKeyboard.Open(mText, (iPhoneKeyboardType)((int)type), autoCorrect);
  8. #else
  9.                                         if (isPassword)
  10.                                         {
  11.                                                 mKeyboard = TouchScreenKeyboard.Open(mText, TouchScreenKeyboardType.Default, false, false, true);
  12.                                         }
  13.                                         else
  14.                                         {
  15.                                                 mKeyboard = TouchScreenKeyboard.Open(mText, (TouchScreenKeyboardType)((int)type), autoCorrect);
  16.                                         }
  17. #endif
  18.                                 }
  19.  

You may want to name the variable Handheld AutoCorrect or something since it only affects builds with Android or iOS.
« Last Edit: August 30, 2012, 12:30:43 PM by Ferazel »