Search code examples
libgdxkotlin

LIBGDX : setPasswordMode not working


So I am building a game in LibGDX (Kotlin) and trying to setup a username and password field.

I create my TextField

password = TextField("", Gui.skin)

I set

password.isPasswordMode = true (Kotin changes setter and getters, under the hode this is calling setPasswordMode)

However the text still appears when I enter it in the box. I am using LibGDX 1.9.6


Solution

  • setPasswordMode will enable the password display mode of a text field.

    How it works is that it replaces each character with a predefined character. By default, this is the bullet "•", which some fonts may not have.

    Change the password character to something else your font does have, like "*" for example:

    password.setPasswordCharacter('*')
    

    Note that you cannot do

    password.passwordCharacter = '*'
    

    because there is no corresponding getPasswordCharacter method, so no Kotlin property is generated.