morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::TextInputWidget Class Referenceabstract

An editable text field. More...

#include <backend.hpp>

Inheritance diagram for morph::ui::TextInputWidget:
morph::ui::FieldWidget morph::ui::Widget morph::ui::testing::detail::FakeLeaf< TextInputWidget > morph::ui::testing::detail::FakeField< TextInputWidget > morph::ui::testing::detail::FakeTextInput

Public Member Functions

virtual void setText (std::string_view text)=0
 Replaces the text. Never calls the onChange handler. With the text the field already shows, it changes nothing: the cursor, the selection and an input method's composition stay as they are.
virtual void setPlaceholder (std::string_view placeholder)=0
 Sets the text shown while the field is empty.
virtual void setOnChange (std::function< void(std::string)> onChange)=0
 Sets what a user edit calls, with the whole new text.
virtual void setOnSubmit (std::function< void(std::string)> onSubmit)=0
 Sets what a submit (Enter in single-line mode) calls, with the text.
virtual void setOnCommit (std::function< void(std::string)> onCommit)=0
 Sets what a commit calls, with the text: Enter in single-line mode, before the submit, or focus leaving the field after an edit.
virtual void setUnit (std::string_view unit)=0
 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.
virtual void setDecimals (int decimals)=0
 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.
virtual void setIcon (std::string_view icon)=0
 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.
virtual void setCaption (std::string_view label, bool shown)=0
 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.
Public Member Functions inherited from morph::ui::FieldWidget
virtual void setReadOnly (bool readonly)=0
 Makes the value read-only or editable again. A read-only field still takes focus and lets its text be selected, and reports no edit, submit or commit.
virtual void setRequired (bool required)=0
 Shows or clears the mark of a field that must be given.
virtual void setErrors (std::vector< std::string > const &errors)=0
 Replaces the messages shown with the field.
virtual void setStale (bool stale)=0
 Shows or clears the mark of a value that is being recomputed.
Public Member Functions inherited from morph::ui::Widget
 Widget (Widget const &)=delete
Widget & operator= (Widget const &)=delete
 Widget (Widget &&)=delete
Widget & operator= (Widget &&)=delete
virtual void setVisible (bool visible)=0
 Shows or hides the widget and everything inside it.
virtual void setEnabled (bool enabled)=0
 Enables or disables input on the widget and everything inside it.
virtual void setLayout (LayoutHints const &hints)=0
 Sets the size request.
virtual void setDragKey (std::optional< Key > const &key)=0
 Makes the widget draggable, carrying key, or not draggable.
virtual void setDropHandler (std::function< bool(Key const &)> accepts, std::function< void(Key)> onDrop)=0
 Makes the widget a drop target.
virtual void setAccessibleName (std::string_view name)=0
 Sets the name assistive technology reads for the widget.
virtual void setAccessibleRole (std::string_view role)=0
 Sets the role assistive technology announces for the widget.
virtual void setTestId (std::string_view testId)=0
 Sets the stable identifier an automated test finds the widget by.
virtual void setTooltip (std::string_view text)=0
 Sets the text shown while the pointer rests on the widget.
virtual void setSurface (std::string_view surface)=0
 Styles the widget and everything inside it with a named token set of the theme.
virtual void setKeys (std::vector< std::string > const &chords, std::function< void(std::string)> onChord)=0
 Declares the keyboard chords the widget handles while focus is inside it.
virtual void focus ()=0
 Moves keyboard focus to the widget.
virtual void setOnHover (std::function< void()> onHover)
 Calls onHover each time the pointer comes to rest over the widget. A backend without a pointer, or one that does not report hovering, keeps the default, which never calls it: hovering is a hint, such as a prefetch, never something a widget relies on.

Detailed Description

An editable text field.

Definition at line 178 of file backend.hpp.

Member Function Documentation

◆ setText()

virtual void morph::ui::TextInputWidget::setText ( std::string_view text)
pure virtual

Replaces the text. Never calls the onChange handler. With the text the field already shows, it changes nothing: the cursor, the selection and an input method's composition stay as they are.

Parameters
textThe text, UTF-8.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setPlaceholder()

virtual void morph::ui::TextInputWidget::setPlaceholder ( std::string_view placeholder)
pure virtual

Sets the text shown while the field is empty.

Parameters
placeholderThe text, UTF-8.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setOnChange()

virtual void morph::ui::TextInputWidget::setOnChange ( std::function< void(std::string)> onChange)
pure virtual

Sets what a user edit calls, with the whole new text.

Parameters
onChangeThe handler; empty does nothing.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setOnSubmit()

virtual void morph::ui::TextInputWidget::setOnSubmit ( std::function< void(std::string)> onSubmit)
pure virtual

Sets what a submit (Enter in single-line mode) calls, with the text.

Parameters
onSubmitThe handler; empty does nothing.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setOnCommit()

virtual void morph::ui::TextInputWidget::setOnCommit ( std::function< void(std::string)> onCommit)
pure virtual

Sets what a commit calls, with the text: Enter in single-line mode, before the submit, or focus leaving the field after an edit.

Parameters
onCommitThe handler; empty does nothing.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setUnit()

virtual void morph::ui::TextInputWidget::setUnit ( std::string_view unit)
pure virtual

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.

Parameters
unitThe unit's display text, UTF-8.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setDecimals()

virtual void morph::ui::TextInputWidget::setDecimals ( int decimals)
pure virtual

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.

Parameters
decimalsThe places, from 0; -1 when the input does not hold a number.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setIcon()

virtual void morph::ui::TextInputWidget::setIcon ( std::string_view icon)
pure virtual

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.

Parameters
iconAn icon name of the theme's icon set.

Implemented in morph::ui::testing::detail::FakeTextInput.

◆ setCaption()

virtual void morph::ui::TextInputWidget::setCaption ( std::string_view label,
bool shown )
pure virtual

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.

Parameters
labelThe label, UTF-8.
shownWhether the input shows it.

Implemented in morph::ui::testing::detail::FakeTextInput.


The documentation for this class was generated from the following file: