Toggle TextField.Password

I would like the user to be able to toggle the password property of a TextField by hitting Ctrl-Z. I added this code to the KeyDown event of the TextField. It fires, but does not work.

[quote]Function KeyDown(Key As String) As Boolean
if Key = ChrB(26) Then
me.Password = Not me.Password
end if
End Function
[/quote]

Wouldn’t you want to use the keyboard object to check for control and then the string ‘z’? http://documentation.xojo.com/index.php/Keyboard

If on Windows or Linux, that might never make it to the event anyway since that’s “undo”.

It could be a whole lot easier to use a MenuItem shortcut. However, the choice Ctrl-Z conflicts with the recommended key combination for Undo.

What seems to be the most usual way is a checkbox under the TextField, with “Show Text”.

The checkbox is what I normally use. This is a diagnostic program where the password is normally available to the tech. I am looking for a way that our factory techs using TeamViewer can help the customer’s tech without revealing a secret built-in password that brings up features not available to the normal user.

Ctrl-Z turns out not to be a good choice. Been using RB/Xojo since 2005 and never used the keyboard object before. Cool. Thanks Bob.

For display purposes I use a subclassed Label control that displays the password on a mouse hover, and then reverts to a series of “•” symbols on mouse exit.

[quote=245000:@Dean Davidge]The checkbox is what I normally use. This is a diagnostic program where the password is normally available to the tech. I am looking for a way that our factory techs using TeamViewer can help the customer’s tech without revealing a secret built-in password that brings up features not available to the normal user.

Ctrl-Z turns out not to be a good choice. Been using RB/Xojo since 2005 and never used the keyboard object before. Cool. Thanks Bob.[/quote]

Alt could be a nice pick.