summaryrefslogtreecommitdiff
path: root/Widgets/TextBox.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-13 22:46:34 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-13 22:46:34 +0200
commitdfb70ed234fa82ea88665657af6758250bb54c3a (patch)
tree698be021696df621c2e8b9269275f01ea9dfcdd2 /Widgets/TextBox.h
parent6f1b384cde73b4f701057f009a02f936aaf2b785 (diff)
downloadserenity-dfb70ed234fa82ea88665657af6758250bb54c3a.zip
Start working on a simple TextBox widget.
Diffstat (limited to 'Widgets/TextBox.h')
-rw-r--r--Widgets/TextBox.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/Widgets/TextBox.h b/Widgets/TextBox.h
new file mode 100644
index 0000000000..89a748cb25
--- /dev/null
+++ b/Widgets/TextBox.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "Widget.h"
+
+class TextBox final : public Widget {
+public:
+ explicit TextBox(Widget* parent = nullptr);
+ virtual ~TextBox() override;
+
+ String text() const { return m_text; }
+ void setText(String&&);
+
+private:
+ virtual void onPaint(PaintEvent&) override;
+ virtual void onMouseDown(MouseEvent&) override;
+ virtual void onKeyDown(KeyEvent&) override;
+ virtual void onTimer(TimerEvent&) override;
+
+ void handleBackspace();
+
+ String m_text;
+ unsigned m_cursorPosition { 0 };
+ bool m_cursorBlinkState { false };
+};
+