libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
lineedit.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/namespace.h>
11#include <promeki/string.h>
12#include <promeki/tui/widget.h>
13
14PROMEKI_NAMESPACE_BEGIN
15
23class TuiLineEdit : public TuiWidget {
24 PROMEKI_OBJECT(TuiLineEdit, TuiWidget)
25 public:
26 TuiLineEdit(const String &text = String(), ObjectBase *parent = nullptr);
27 ~TuiLineEdit() override;
28
29 void setText(const String &text);
30 const String &text() const { return _text; }
31
32 void setPlaceholder(const String &text) {
33 _placeholder = text;
34 update();
35 }
36 const String &placeholder() const { return _placeholder; }
37
38 Size2Di32 sizeHint() const override;
39
40 PROMEKI_SIGNAL(textChanged, const String &)
41 PROMEKI_SIGNAL(returnPressed)
42
43 protected:
44 void paintEvent(PaintEvent *e) override;
45 void keyPressEvent(KeyEvent *e) override;
46 void focusInEvent(Event *e) override;
47 void focusOutEvent(Event *e) override;
48
49 private:
50 String _text;
51 String _placeholder;
52 int _cursorPos = 0;
53 int _scrollOffset = 0;
54};
55
56PROMEKI_NAMESPACE_END
Single-line text input widget.
Definition lineedit.h:23
TUI-specific widget base class.
Definition widget.h:33