element
widgets<element id='number-of-copies'> <input_field>1</input_field> <config> <columns>6</columns> <alignment>right</alignment> <maximum_size>5</maximum_size> <autoselect /> <set_default_spin_control_factories /> </config> </element>
Specifying an element
with a input_field
creates a new theme widget
which is an
x::w::input_field
widget.
This is equivalent to invoking the factory's
create_input_field
() method.
The value of the input_field
sets the initial
contents of the input field (the first parameter to
create_input_field
()). It may be empty:
<input_field />
input_field
element's value is a
x::w::text_param
value, the first parameter to
create_input_field
(); this sets the
input field's initial contents (fonts, colors, and other visual
markup references are not allowed,
of course, and any literal “$” should be doubled as
“$$”).
An optional config
element initializes the
x::w::input_field_config
parameter for create_input_field
, as
follows:
columns
,
rows
, and
maximum_size
Sets the corresponding members in the
x::w::input_field_config
parameter.
<autoselect/>
and
<autodeselect/>
Sets the corresponding flags in the
x::w::input_field_config
parameter.
<disable_clipboards/>
Sets
x::w::input_field_config
's
update_clipboards
to false
.
hint
Sets the
x::w::input_field_config
's
hint
x::w::text_param
value.
<password/>
Invokes x::w::input_field_config
's
set_password
() method, configuring this
input field as a password
input field.
<set_default_spin_control_factories/>
Invokes x::w::input_field_config
's
set_default_spin_control_factories
()
method, enabling this
input field's spin buttons.
<enable_search/>
Invokes x::w::input_field_config
's
enable_search
()
method, enabling this
input field's search popup.
vertical_scrollbar
This element contains an x::w::scrollbar_visibility
value that sets
the corresponding
member of ths
x::w::input_field_config
parameter.
alignment
This element contains an x::w::halign
value that sets the corresponding
member of ths
x::w::input_field_config
parameter.
direction
The input field's text direction.
directional_format
The input field's default bi-directional text format.
appearance
Sets the input field's
appearance
object.
It is possible to use a theme file to create a validated input field.
<element id='items'> <input_field /> </element> #include <x/w/validated_input_field.H> x::w::uielements widgets; widgets.create_validated_input_field( "items", [] (ONLY IN_THREAD, const std::string &value, const auto &lock, const auto &ignore) -> std::optional<int> { // ... }, [] (const std::optional<int> &v) { // ... } ); widgets.create_string_validated_input_field<int>( "items", [] (ONLY IN_THREAD, const std::string &value, std::optional<int> &parsed_value, const auto &lock, const auto &ignore) { // ... }, [] (const std::optional<int> &v) { // ... } ); // Generate the UI x::w::input_field items=widgets.get_element("items"); x::w::validated_input_field<int> items_value= widgets.get_validated_input_field<int>("items");
Calling
created_validated_input_field
() or
created_string_validated_input_field
()
creates a input field validator that's bound to the
input_field
element
with the given identifier. Generating an input field using the
theme file automatically creates it with the specified validator.
The remaining parameters are the same as the parameters to
x::w::create_validated_input_field_contents
() and
x::w::create_string_validated_input_field_contents
().
The initial contents of the input field in the theme file get
ignored, and <input_field/>
is an
empty tag. The initial contents come from the optional initial
value parameter to
x::w::create_validated_input_field_contents
() and
x::w::create_string_validated_input_field_contents
().
The get_validated_input_field
() retrieves
the
x::w::validated_input_field<type>
of the created input field.