Author Topic: UIInput show numberpad with InputType password on mobile  (Read 9485 times)

caiorosisca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
UIInput show numberpad with InputType password on mobile
« on: April 14, 2015, 05:05:27 PM »
I´m  trying to have a password input field that only allows to put in numbers, and I want to open up only the numberpad keyboard when typing on it.
I tried setting validation to  Integer and Mobile Keyboard to NumberPad, works fine if InputType is set to Standard, if I switch it to password the app opens up the full keyboard.
How can I solve this?

caiorosisca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #1 on: April 15, 2015, 08:31:28 AM »
I´ve found this line on UIInput class, inside the Update() method, line 602:

  1. kt = TouchScreenKeyboardType.Default;

Can someone explain to me why that is necessary?
I guess it has something to do with the problem, but I still can´t find a solution.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #2 on: April 16, 2015, 07:28:05 AM »
I don't remember why it was necessary... It may have been some bug in Unity back in the day. If it works for you when you replace that line with
  1. kt = (TouchScreenKeyboardType)((int)keyboardType);
...then just keep it.

caiorosisca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #3 on: July 13, 2015, 08:16:45 AM »
I just realised I never answered to this topic, just saying that this solution did work.

Aastha

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #4 on: July 20, 2015, 11:50:38 PM »
Hi,

I am also facing some issue with number pad keyboard. In my case I have to add contact number in textfield.
I set the "Input type" to standard, "Validation" to integer, and "Mobile keyboard" to number pad but on clicking the textfield field first time, it opens default keyboard and after that it opens number pad every time the textfield is clicked.
Please help me to fix the issue.
« Last Edit: July 20, 2015, 11:58:29 PM by Aastha »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #5 on: July 21, 2015, 11:54:50 AM »
This topic isn't the same as what you're experiencing, Aastha. The OP wanted to use a number-only keyboard with a password type. You have a number-only keyboard, but aren't using a password type. I'm not sure why it opens the default keyboard for you the first time. Check the code of UIInput's Update function around line 642 or 629, depending on whether your keyboard input was chosen to be hidden or not. In either case the keyboard type is set to what you chose, and it gets passed to the TouchScreenKeyboard.Open function used to actually open the keyboard on line 648 (which is a Unity call).

Aastha

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #6 on: July 22, 2015, 04:55:53 AM »
I understand that I am not using it as password but on converting it to password with number pad the issue is same. It shows number pad when keyboard is half way to open then it changes to default keyboard.
In xcode a warning appears :
Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad; using 2705787216_PortraitChoco_iPhone-Simple-Pad_Default

But for second time also the warning is same and number pad is opening.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput show numberpad with InputType password on mobile
« Reply #7 on: July 24, 2015, 10:13:24 AM »
Perhaps platform defines changed? Try replacing UIInput.KeyboardType enum with this:
  1. #if UNITY_EDITOR
  2.         public enum KeyboardType
  3.         {
  4.                 Default = (int)TouchScreenKeyboardType.Default,
  5.                 ASCIICapable = (int)TouchScreenKeyboardType.ASCIICapable,
  6.                 NumbersAndPunctuation = (int)TouchScreenKeyboardType.NumbersAndPunctuation,
  7.                 URL = (int)TouchScreenKeyboardType.URL,
  8.                 NumberPad = (int)TouchScreenKeyboardType.NumberPad,
  9.                 PhonePad = (int)TouchScreenKeyboardType.PhonePad,
  10.                 NamePhonePad = (int)TouchScreenKeyboardType.NamePhonePad,
  11.                 EmailAddress = (int)TouchScreenKeyboardType.EmailAddress,
  12.         }
  13. #else
  14.         public enum KeyboardType
  15.         {
  16.                 Default = 0,
  17.                 ASCIICapable = 1,
  18.                 NumbersAndPunctuation = 2,
  19.                 URL = 3,
  20.                 NumberPad = 4,
  21.                 PhonePad = 5,
  22.                 NamePhonePad = 6,
  23.                 EmailAddress = 7,
  24.         }
  25. #endif
...Or just compare the value of TouchScreenKeyboard.NumberPad with KeyboardType.NumberPad. Do they match? It should be '4'. It's a Unity-provided value.