1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:08:12 +00:00

LibGUI: Add button to PasswordBox to reveal the password

This patch adds an eye-like button to the PasswordBox
which allows the user to reveal the typed password.
Whether or not the button is shown is controllable via
an additional property within the PasswordBox.
This commit is contained in:
faxe1008 2022-05-07 17:14:09 +02:00 committed by Linus Groh
parent 448d6b9acc
commit 86d5e5a90c
2 changed files with 66 additions and 1 deletions

View file

@ -42,8 +42,23 @@ private:
class PasswordBox : public TextBox {
C_OBJECT(PasswordBox)
public:
bool is_showing_reveal_button() const { return m_show_reveal_button; }
void set_show_reveal_button(bool show)
{
m_show_reveal_button = show;
update();
}
private:
PasswordBox();
virtual void paint_event(PaintEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
Gfx::IntRect reveal_password_button_rect() const;
bool m_show_reveal_button { false };
};
class UrlBox : public TextBox {