Hi,
I have just submitted a bug report, case 46483…
When building an app where I want a secure field for a numeric PIN, I have noticed that on Android the two flags for a native.newTextField() override each other.
I haven’t tested on iOS yet, but Android certainly has the issue. Basically if you set a field to isSecure=true and then change the keyboard type by e.g. inputType=number, the isSecure flag is reset to false and the input on screen is not hidden by the black dots.
if you do it the other way around (first set input type, then set the issecure flag), then the input is obscured correctly, but the input type is ignored and always shows the default keyboard, not the “number” type one.
on windows simulator it works fine, but when built and installed on device, the bug becomes apparent.
i have also tried setting the inputType to “phone” and “decimal” – sadly with exactly the same results
I have noticed this has already been reported back in 2014 (https://forums.coronalabs.com/topic/52147-native-text-field-using-inputtype-on-android/) , but apparently never fixed.
Is anybody aware of any workarounds, how to get an obscured PIN field with numeric input keyboard only?
You can use the following code to see for yourself:
local fieldWidth = display.contentWidth \* 0.5 local fieldHeight = display.contentHeight \* 0.1 local inputFontSize = display.contentHeight \* 0.08 -- first field sets isSecure flag first and then changes keyboard type. -- the result is that the isSecure is ignored, although the keyboard is set correctly to a numeric one. -- since isSecure is ignored, input in the fields is fully visible (not obfuscated by the black dots) inputFieldOne = native.newTextField( display.contentWidth \* 0.5, display.contentHeight \* 0.25, fieldWidth, fieldHeight, inputFontSize ) inputFieldOne.isSecure = true inputFieldOne.inputType = "number" -- second field sets inputType first and then sets the isSecure flag -- the result is that the the inputType is ignored and Android always displays default keyboard. -- isSecure flag remains true and the input in the field is hidden by the black dots as it should be. inputFieldTwo = native.newTextField( display.contentWidth \* 0.5, display.contentHeight \* 0.75, fieldWidth, fieldHeight, inputFontSize ) inputFieldTwo.inputType = "number" inputFieldTwo.isSecure = true