Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: shaun9991 on Thu 07/03/2019 21:14:15

Title: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: shaun9991 on Thu 07/03/2019 21:14:15
Hey guys!

I've tried to find a solution for this but no avail as yet. There is a section in our next game when the player needs to enter a password on a computer screen. Rather than the password simply showing as typed in the Textbox, is there a way of displaying all text characters typed within that Textbox as an 'x', for example? I think I've seen this in AGS games before.

Many thanks! Any help is super appreciated  :)
Shaun
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: Privateer Puddin' on Thu 07/03/2019 21:25:07
A font where every character is an x?
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: shaun9991 on Thu 07/03/2019 21:38:48
Great idea!! I will try that. Thanks :)
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: Khris on Fri 08/03/2019 08:08:46
The other way is to use a Label and add an X to a string when the player presses a keyboard key and the password GUI is visible.
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: shaun9991 on Sat 09/03/2019 18:18:00
Thanks Khris! I've been trying your suggestion but I can't get it to work correctly. Would this be using the Append/AppendChar string functions?

Thanks!
Shaun
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: Khris on Sat 09/03/2019 18:58:28
Yes, something like

Code (ags) Select
  // in on_key_press

  if (gPassword.Visible) {
    password = password.AppendChar(k);  // k is the eKeyCode param
    xString = xString.AppendChar('X');
    lblPassword.Text = xString;
  }
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: shaun9991 on Sat 09/03/2019 23:42:34
Awesome, thanks Khris - I managed to get it working with your help :)
Title: Re: Replacing characters in a Textbox with 'x' when player is entering a password
Post by: Gurok on Tue 12/03/2019 01:41:54
Be sure to remove a character when backspace is pressed too!