How to use PasswordBox on Android?
Posted: 19 May 2014, 14:35
Noesis (and WPF) provide a PasswordBox control to let the user enter a password.
In the Unity player (on Windows) this works perfectly, but on Android it doesn't:
* First of all, while typing all the characters are visible. Typically on Android, all the characters would be replaced by '*' except the last entered character which is displayed for a short time.
* But more importantly, the data that is entered by the user is never actually copied into the PasswordBox!
XAML code:
Code-behind:
In the Unity player (on Windows) this works perfectly, but on Android it doesn't:
* First of all, while typing all the characters are visible. Typically on Android, all the characters would be replaced by '*' except the last entered character which is displayed for a short time.
* But more importantly, the data that is entered by the user is never actually copied into the PasswordBox!
XAML code:
Code: Select all
<PasswordBox PasswordChar="*" x:Name="_passwordBox"/>Code: Select all
public LogInV()
{
this.Loaded += LogInV_Loaded;
}
void LogInV_Loaded(BaseComponent sender, RoutedEventArgs e)
{
_passwordBox = FindName<PasswordBox>("_passwordBox");
if (_passwordBox == null)
{
_log.Log("_passwordBox not found");
return;
}
_passwordBox.PasswordChanged += _passwordBox_PasswordChanged;
}
void _passwordBox_PasswordChanged(BaseComponent sender, RoutedEventArgs e)
{
// THIS CODE WILL NEVER BE INVOKED ON ANDROID![/color]
var password = _passwordBox.GetPassword();
_log.Log("password changed: [" + password + "]");
}