iOS Question TextField passwordmode toggling with Custom Fonts

TnP

Member
Licensed User
Hi All,
I have a project with a log-in screen using a TextField for the password entry. I am using a Custom Font on this TextField.

I also have a 'show password' Switch to toggle the 'passwordmode' on the TextField by servicing the _ValueChanged event for the Switch.

I have found that if I toggle the Switch on and off multiple times, the Custom Font is lost and it reverts to a default font.

Am I doing something wrong or is this a bug? I've attached an example project to illustrate the behaviour.
Thanks,
Terry
 

Attachments

Erel

Administrator
Staff member
Licensed User
Doesn't happen here. If it is a bug it is a bug in the OS itself as the password mode is a native feature.

Try this workaround:
B4X:
Sub Switch1_ValueChanged (Value As Boolean)
   TextField1.PasswordMode = Value
   Sleep(10)
   If Value Then
       TextField1.Font = Font.CreateNew2("Adventure", 30)
   End If
End Sub
Note that the text size will be reset when you rotate the screen based on the size set in the layout file (because of the call to AutoScaleAll).
 

TnP

Member
Licensed User
Thanks Erel, but no change here unfortunately. I had tried something similar myself earlier.
For the record, I'm using a 3rd Gen iPad with iOS9 to test.
I tried it on the Simulator (on a VM) and it seemed to work on iOS11, so I agree it may be OS bug related.
 
Top