Bladeren bron

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.
Max Wipfli 4 jaren geleden
bovenliggende
commit
9f0ce2dc81
2 gewijzigde bestanden met toevoegingen van 15 en 0 verwijderingen
  1. 8 0
      Userland/Libraries/LibGUI/TextBox.cpp
  2. 7 0
      Userland/Libraries/LibGUI/TextBox.h

+ 8 - 0
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);
+}
+
 }

+ 7 - 0
Userland/Libraries/LibGUI/TextBox.h

@@ -6,6 +6,7 @@
 
 #pragma once
 
+#include <LibGUI/Action.h>
 #include <LibGUI/TextEditor.h>
 
 namespace GUI {
@@ -36,4 +37,10 @@ private:
     String m_saved_input;
 };
 
+class PasswordBox : public TextBox {
+    C_OBJECT(PasswordBox)
+public:
+    PasswordBox();
+};
+
 }