From 9f0ce2dc818df8b5b8cd77d8c297bed237a9a250 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Fri, 25 Jun 2021 17:59:50 +0200 Subject: LibGUI: Add PasswordBox This patch adds a PasswordBox. At the moment, it's simply a TextBox with it's substitution code point set to '*', and the undo and redo actions disabled. --- Userland/Libraries/LibGUI/TextBox.cpp | 8 ++++++++ Userland/Libraries/LibGUI/TextBox.h | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibGUI/TextBox.cpp b/Userland/Libraries/LibGUI/TextBox.cpp index 8b64774c1f..45a28ac086 100644 --- a/Userland/Libraries/LibGUI/TextBox.cpp +++ b/Userland/Libraries/LibGUI/TextBox.cpp @@ -72,4 +72,12 @@ void TextBox::add_input_to_history(String input) m_history_index++; } +PasswordBox::PasswordBox() + : TextBox() +{ + set_substitution_code_point('*'); + undo_action().set_enabled(false); + redo_action().set_enabled(false); +} + } diff --git a/Userland/Libraries/LibGUI/TextBox.h b/Userland/Libraries/LibGUI/TextBox.h index 9a2ff26af5..374f579e0a 100644 --- a/Userland/Libraries/LibGUI/TextBox.h +++ b/Userland/Libraries/LibGUI/TextBox.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace GUI { @@ -36,4 +37,10 @@ private: String m_saved_input; }; +class PasswordBox : public TextBox { + C_OBJECT(PasswordBox) +public: + PasswordBox(); +}; + } -- cgit v1.2.3