|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
A fake TextInputWidget: properties mode, text, placeholder, unit, decimals, icon, caption, captionShown, the field state, and a text cursor. More...
#include <recording_backend.hpp>
Public Member Functions | |
| void | setText (std::string_view text) override |
| Records property text; moves the cursor to the end only when the text changes. | |
| void | typedByUser (std::string text, std::size_t cursor) |
The text the user typed: the field shows it, and the cursor is at cursor; nothing is logged. | |
| void | moveCursorByUser (std::size_t cursor) noexcept |
| Moves the cursor as the user's arrow keys or a click would. | |
| std::size_t | cursor () const noexcept |
| Where the cursor is. | |
| std::string const & | text () const noexcept |
| The text the field shows. | |
| void | setPlaceholder (std::string_view placeholder) override |
| Sets the text shown while the field is empty. | |
| void | setUnit (std::string_view unit) override |
| Sets the unit the input shows, muted, at its trailing edge, inside the field; empty shows none. Called only on a single-line or password input. | |
| void | setDecimals (int decimals) override |
| Sets the fraction digits a number is entered with: what a backend or a kit may use to align or format the text. Nothing is required of a backend that draws nothing from it. Called only on a single-line or password input. | |
| void | setIcon (std::string_view icon) override |
| Sets the icon drawn at the field's leading edge; empty shows none. Called once, and only for a single-line or password input that has one. | |
| void | setCaption (std::string_view label, bool shown) override |
| Sets the field's label, and whether the input draws it as a visible caption above its control. Without shown, the caption is drawn elsewhere (a form's cell), or not at all. | |
| void | setOnChange (std::function< void(std::string)> onChange) override |
| Sets what a user edit calls, with the whole new text. | |
| void | setOnSubmit (std::function< void(std::string)> onSubmit) override |
| Sets what a submit (Enter in single-line mode) calls, with the text. | |
| void | setOnCommit (std::function< void(std::string)> onCommit) override |
| Sets what a commit calls, with the text: Enter in single-line mode, before the submit, or focus leaving the field after an edit. | |
| Public Member Functions inherited from morph::ui::testing::detail::FakeField< TextInputWidget > | |
| void | setReadOnly (bool readonly) override |
| Records property readonly; RecordingBackend's edits leave a read-only field alone. | |
| void | setRequired (bool required) override |
| Records property required. | |
| void | setErrors (std::vector< std::string > const &errors) override |
| Records property errors, as formatList gives the messages. | |
| void | setStale (bool stale) override |
| Records property stale. | |
| Public Member Functions inherited from morph::ui::testing::detail::FakeLeaf< TextInputWidget > | |
| FakeLeaf (std::shared_ptr< RecordStore > store, std::string kind, ContainerWidget const *parent, PropList initial={}) | |
Records the new widget, appended to parent, and logs its creation. | |
| ~FakeLeaf () override | |
| Forgets the widget and logs its destruction; its remaining children become roots. | |
| FakeLeaf & | operator= (FakeLeaf const &)=delete |
| void | setVisible (bool visible) override |
| Records property visible. | |
| void | setEnabled (bool enabled) override |
| Records property enabled. | |
| void | setLayout (LayoutHints const &hints) override |
| Records property layout, as formatLayout gives it. | |
| void | setDragKey (std::optional< Key > const &key) override |
| Records property dragKey and keeps the key for RecordingBackend::drag. | |
| void | setDropHandler (std::function< bool(Key const &)> accepts, std::function< void(Key)> onDrop) override |
| Records property drop=handler and keeps both handlers for RecordingBackend::drag. | |
| void | setAccessibleName (std::string_view name) override |
| Records property a11yName. | |
| void | setAccessibleRole (std::string_view role) override |
| Records property a11yRole. | |
| void | setTestId (std::string_view testId) override |
| Records property testId. | |
| void | setTooltip (std::string_view text) override |
| Records property tooltip. | |
| void | setSurface (std::string_view surface) override |
| Records property surface. | |
| void | setKeys (std::vector< std::string > const &chords, std::function< void(std::string)> onChord) override |
| Records property keys, the chords joined by commas, and keeps the chords and the handler for RecordingBackend::press. | |
| void | focus () override |
| Moves the backend's recorded focus here, and logs focus. | |
| void | setOnHover (std::function< void()> onHover) override |
| Keeps the handler for RecordingBackend::hover. | |
| Public Member Functions inherited from morph::ui::Widget | |
| Widget (Widget const &)=delete | |
| Widget & | operator= (Widget const &)=delete |
| Widget (Widget &&)=delete | |
| Widget & | operator= (Widget &&)=delete |
Additional Inherited Members | |
| Protected Member Functions inherited from morph::ui::testing::detail::FakeLeaf< TextInputWidget > | |
| void | set (std::string_view name, std::string value) |
| Records a property set through a setter. | |
| Callbacks & | callbacks () |
| This widget's handlers. | |
| RecordStore & | store () const noexcept |
| The store this widget records into. | |
| std::shared_ptr< RecordStore > const & | sharedStore () const noexcept |
| The store, shared: what a part this widget makes (an overlay's footer) records into. | |
| int | id () const noexcept |
| This widget's id. | |
A fake TextInputWidget: properties mode, text, placeholder, unit, decimals, icon, caption, captionShown, the field state, and a text cursor.
The cursor is a byte offset into the text. A user's edit puts it where the edit left it; setText with the text the field shows leaves it alone, as the contract requires, and setText with another text puts it at the end.
Definition at line 906 of file recording_backend.hpp.
|
inlineoverridevirtual |
Records property text; moves the cursor to the end only when the text changes.
| text | The text, UTF-8. |
Implements morph::ui::TextInputWidget.
Definition at line 912 of file recording_backend.hpp.
|
inline |
The text the user typed: the field shows it, and the cursor is at cursor; nothing is logged.
| text | The whole new text. |
| cursor | Where the cursor ends up; clamped to the text's size. |
Definition at line 923 of file recording_backend.hpp.
|
inlinenoexcept |
Moves the cursor as the user's arrow keys or a click would.
| cursor | The new position; clamped to the text's size. |
Definition at line 931 of file recording_backend.hpp.
|
inlinenodiscardnoexcept |
Where the cursor is.
Definition at line 935 of file recording_backend.hpp.
|
inlinenodiscardnoexcept |
The text the field shows.
Definition at line 939 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets the text shown while the field is empty.
| placeholder | The text, UTF-8. |
Implements morph::ui::TextInputWidget.
Definition at line 941 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets the unit the input shows, muted, at its trailing edge, inside the field; empty shows none. Called only on a single-line or password input.
| unit | The unit's display text, UTF-8. |
Implements morph::ui::TextInputWidget.
Definition at line 942 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets the fraction digits a number is entered with: what a backend or a kit may use to align or format the text. Nothing is required of a backend that draws nothing from it. Called only on a single-line or password input.
| decimals | The places, from 0; -1 when the input does not hold a number. |
Implements morph::ui::TextInputWidget.
Definition at line 943 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets the icon drawn at the field's leading edge; empty shows none. Called once, and only for a single-line or password input that has one.
| icon | An icon name of the theme's icon set. |
Implements morph::ui::TextInputWidget.
Definition at line 944 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets the field's label, and whether the input draws it as a visible caption above its control. Without shown, the caption is drawn elsewhere (a form's cell), or not at all.
| label | The label, UTF-8. |
| shown | Whether the input shows it. |
Implements morph::ui::TextInputWidget.
Definition at line 945 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets what a user edit calls, with the whole new text.
| onChange | The handler; empty does nothing. |
Implements morph::ui::TextInputWidget.
Definition at line 949 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets what a submit (Enter in single-line mode) calls, with the text.
| onSubmit | The handler; empty does nothing. |
Implements morph::ui::TextInputWidget.
Definition at line 950 of file recording_backend.hpp.
|
inlineoverridevirtual |
Sets what a commit calls, with the text: Enter in single-line mode, before the submit, or focus leaving the field after an edit.
| onCommit | The handler; empty does nothing. |
Implements morph::ui::TextInputWidget.
Definition at line 951 of file recording_backend.hpp.