Allow user to copy text from a password field
The usual way is to have a button right to the edit field allowing to display the password. This may be bound to some access conditions. While the password is visible it can be copied as well.
This is just a minor extension to Uwe Raabe's correct answer; please prefer to upvote/accept his answer.
You could actually choose to have two buttons next to the password edit control1:
- One that displays the password on-screen (that is, sets
PasswordChar = #0). This can be made either temporarily while the button is being depressed, or it can toggle between the two states on each click. (If you choose the first method, remember that the UI has to be 100% usable without a mouse, only using the keyboard.)
- One that copies the password to clipboard.
Firefox offers this dual functionality, and I find it very convenient to be able to put the password in clipboard without it ever been visible on-screen.
Optionally, you may require some security check before any of the actions. For instance, Firefox asks for the master password (if present).
1 Make sure both buttons can be used both with the mouse and with the keyboard. In particular, this means that you cannot use
TSpeedButton controls (at least not without additional effort).
TBitBtn is OK, though. Also make sure the tab order is correct: from left to right. It is a good idea to create a new custom control with this three-control constellation. I'd advice you to let the buttons have tooltips:
Show password and
Copy password, respectively.