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

A choice of one keyed option. More...

#include <backend.hpp>

Inheritance diagram for morph::ui::SelectWidget:
morph::ui::FieldWidget morph::ui::Widget morph::ui::testing::detail::FakeLeaf< SelectWidget > morph::ui::testing::detail::FakeField< SelectWidget > morph::ui::testing::detail::FakeSelect

Public Member Functions

virtual void setOptions (std::vector< SelectOption > const &options)=0
 Replaces the options, and marks the requested key's option if they contain it.
virtual void setSelected (std::optional< Key > const &key)=0
 Requests the option with key. It is marked while the options contain it; otherwise none is marked. Never calls onSelect.
virtual void setOnSelect (std::function< void(Key)> onSelect)=0
 Sets what a user choice calls, with the option's key.
virtual void setOnOpen (Action onOpen)
 Calls onOpen each time the user opens the dropdown, also when it has no options to show. A radio group, and a backend that does not report opening, keep the default, which never calls it: opening is a hint, such as a retry of a failed fetch of the options, never something a select relies on.
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

A choice of one keyed option.

The widget keeps the key last requested by setSelected or chosen by the user, and marks the option with that key whenever the current options contain one. A key outside the options marks none, and stays requested: options that bring it back mark it again. Options and selection may therefore arrive in either order.

Definition at line 246 of file backend.hpp.

Member Function Documentation

◆ setOptions()

virtual void morph::ui::SelectWidget::setOptions ( std::vector< SelectOption > const & options)
pure virtual

Replaces the options, and marks the requested key's option if they contain it.

Parameters
optionsThe options, in order.

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

◆ setSelected()

virtual void morph::ui::SelectWidget::setSelected ( std::optional< Key > const & key)
pure virtual

Requests the option with key. It is marked while the options contain it; otherwise none is marked. Never calls onSelect.

Parameters
keyThe key, or nullopt for no selection.

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

◆ setOnSelect()

virtual void morph::ui::SelectWidget::setOnSelect ( std::function< void(Key)> onSelect)
pure virtual

Sets what a user choice calls, with the option's key.

Parameters
onSelectThe handler; empty does nothing.

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

◆ setOnOpen()

virtual void morph::ui::SelectWidget::setOnOpen ( Action onOpen)
inlinevirtual

Calls onOpen each time the user opens the dropdown, also when it has no options to show. A radio group, and a backend that does not report opening, keep the default, which never calls it: opening is a hint, such as a retry of a failed fetch of the options, never something a select relies on.

Parameters
onOpenThe handler; empty stops calling one.

Reimplemented in morph::ui::testing::detail::FakeSelect.

Definition at line 266 of file backend.hpp.

◆ setCaption()

virtual void morph::ui::SelectWidget::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::FakeSelect.


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