.. index:: pair: class; EE::UI::UIValueBinding .. _doxid-class_e_e_1_1_u_i_1_1_u_i_value_binding: template class EE::UI::UIValueBinding ===================================== .. toctree:: :hidden: struct_EE_UI_UIValueBinding_State.rst Overview ~~~~~~~~ Move-only two-way binding between an :ref:`ObservableValue ` and a :ref:`UIWidget ` property. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class UIValueBinding { public: // typedefs typedef :ref:`UIValueConverter` :target:`Converter`; // structs struct :ref:`State`; // construction :target:`UIValueBinding`(); :target:`UIValueBinding`(const UIValueBinding&); :target:`UIValueBinding`(UIValueBinding&&); :target:`UIValueBinding`(:ref:`ObservableValue`& value, :ref:`UIWidget`* widget, const :ref:`Converter`& converter = :ref:`converterDefault`(), const std::string& propertyName = "value", :ref:`Event::EventType` eventType = Event::OnValueChange); // methods static :ref:`Converter` :target:`converterDefault`(); UIValueBinding& :target:`operator=`(const UIValueBinding&); UIValueBinding& :target:`operator=`(UIValueBinding&&); void :target:`disconnect`(); :target:`operator bool`() const; bool :target:`isValid`() const; :ref:`UIValueValidationState`* :ref:`validationState`(); const :ref:`UIValueValidationState`* :target:`validationState`() const; }; .. _details-class_e_e_1_1_u_i_1_1_u_i_value_binding: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Move-only two-way binding between an :ref:`ObservableValue ` and a :ref:`UIWidget ` property. The converter maps directly between T and the widget property string. Its toValue() callback decides whether widget input may enter the model. Model-originated values are authoritative and are formatted through fromValue(). Destroying the binding disconnects both directions. Destroying either the observable or widget first is safe and does not keep that endpoint alive. Synchronization is immediate and single-threaded. The observable, widget, and binding must all be used on the widget's owning :ref:`UI ` thread. Use :ref:`UIValueBinding ` when an :ref:`ObservableValue ` belongs to a UI-independent model. The returned binding must be retained for as long as synchronization is desired. .. ref-code-block:: cpp ObservableValue userName{ "Ada" }; auto binding = bindValue( userName, textInput, UIValueConverter::converterString(), "text", Event::OnTextChanged ); userName = "Grace"; // Updates textInput without coupling the model to UIWidget. Methods ------- .. index:: pair: function; validationState .. _doxid-class_e_e_1_1_u_i_1_1_u_i_value_binding_1a8b60f0f33e2786e8d180c117ec4b13a3: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`UIValueValidationState`* validationState() .. rubric:: Returns: Observable conversion and input-validation state.