PasswordWidgetclass represents an interface widget that displays an editable text box for passwords.
class PasswordWidget final : public EditTextWidget
||Returns the password entered into the editable text box.|
PasswordWidget(const Vector2D& size, int32 charCount, const char *font = nullptr, float em = kDefaultFontSize, bool secure = false);
||The size of the text box, in pixels.|
||The maximum number of characters that can be entered into the text box.|
||The name of the font in which the password dots are displayed.|
||The em size of the font, in pixels.|
||Indicates whether security features are enabled.|
PasswordWidgetclass is a special type of
EditTextWidgetthat is intended for password entry. The specific characteristics that differentiate a password widget from an ordinary editable text widget are as follows.
1. The text displayed in the text box is always a sequence of dot characters (Unicode value U+2022).
2. If the user attempts to copy text from a password widget, then only the dot characters are copied.
3. If security features are enabled, the memory occupied by the actual password text is locked in physical memory during the lifetime of the password widget, and the memory is immediately erased when the password widget is destroyed. This prevents the password from being written to a swap file or persisting in unallocated memory.
TextWidget::GetTextfunction cannot retrieve the password string from a password widget. Instead, the
PasswordWidget::GetPasswordfunction should be used. If the
true, then security features are enabled to prevent the password from being leaked into the swap file or unallocated memory. The security features cannot be enabled or disabled after a password widget has been constructed. An application should ensure that no more than one secure password widget exists at any point in time. This avoids the improbable but possible case that two password widgets use the same virtual page in memory and the destruction of one password widget inadvertently unlocks the memory used by the other password widget.