1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:57:46 +00:00

Start working on a simple TextBox widget.

This commit is contained in:
Andreas Kling 2018-10-13 22:46:34 +02:00
parent 6f1b384cde
commit dfb70ed234
7 changed files with 201 additions and 2 deletions

25
Widgets/TextBox.h Normal file
View file

@ -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 };
};