TinyMaterialDesign
Loading...
Searching...
No Matches
TextInputTarget.h
Go to the documentation of this file.
1#pragma once
2
3namespace tinymd {
4
5/**
6 * @brief Minimal interface a Keyboard drives.
7 *
8 * TextField and TextArea both implement this alongside Widget<RGB_T>, so a
9 * single Keyboard can serve either kind of field interchangeably via
10 * Keyboard::manage() - it only ever talks to its target through this
11 * interface, never caring which concrete widget it's driving.
12 *
13 * Not templated on RGB_T: character insertion has nothing to do with pixel
14 * format, and keeping this interface non-generic is what lets Keyboard
15 * (which *is* templated on RGB_T, since it draws itself) hold a single
16 * `TextInputTarget*` regardless of the field's color type.
17 */
18/// What a text input expects: a Keyboard shows its numeric keypad for
19/// kNumber.
20enum class InputType { kText, kNumber };
21
23 public:
24 virtual ~TextInputTarget() = default;
25
26 /// The kind of input - Keyboard picks its layout from it. Default: text.
27 virtual InputType inputType() const { return InputType::kText; }
28
29 virtual void insertChar(char c) = 0;
30 virtual void backspace() = 0;
31 virtual void blur() = 0;
32
33 /// Called when the keyboard's Done key is tapped (a separate Enter key
34 /// handles literal newlines via insertChar('\n') directly, without going
35 /// through this). @return true if the keyboard should hide itself
36 /// afterward - both TextField and TextArea return true here, since Done
37 /// always means "finished editing", but the interface leaves room for a
38 /// future field that wants Done to keep editing open instead.
39 virtual bool handleEnter() = 0;
40};
41
42} // namespace tinymd
Definition: TextInputTarget.h:22
virtual bool handleEnter()=0
virtual void blur()=0
virtual ~TextInputTarget()=default
virtual void insertChar(char c)=0
virtual InputType inputType() const
The kind of input - Keyboard picks its layout from it. Default: text.
Definition: TextInputTarget.h:27
virtual void backspace()=0
Definition: AnchorLayout.h:4
InputType
Minimal interface a Keyboard drives.
Definition: TextInputTarget.h:20