Skip to main content

InputField Binders

Binders for TMP_InputField with two-way binding, numeric types and the various field events.


InputFieldBinder

The main text input binder.

InterfaceDescription
IBinder<string?>Receives text from the ViewModel
IReverseBinder<string>Sends changes back
INumberBinderAccepts numeric types
INumberReverseBinderSends numbers back

Inspector properties

PropertyDescription
UpdateEventUpdate event: OnValueChanged, OnEndEdit, OnSubmit, OnSelect, OnDeselect
ConverterIConverter<string?, string?> (optional)

Loop protection

The _isNotifyValueChanged flag prevents infinite recursion in TwoWay binding: while the ViewModel updates the InputField, the reverse event is blocked.

Numeric modes

With ContentType IntegerNumber or DecimalNumber the string is parsed into a number and sent through INumberReverseBinder.

Modes: OneWay, TwoWay, OneTime, OneWayToSource.

[ViewModel]
public partial class FormViewModel
{
[TwoWayBind] private string _userName;
}

Additional binders

BinderBindsType
InputFieldCharacterValidationBindercharacterValidationCharacterValidation
InputFieldContentTypeBindercontentTypeContentType
InputFieldInputTypeBinderinputTypeInputType
InputFieldLineTypeBinderlineTypeLineType

Each has a Switcher variant (bool → one of two values). ForceLabelUpdate is called after the write.

BinderBindsType
InputFieldCharacterLimitBindercharacterLimitint, 0 for no limit
InputFieldCaretPositionBindercaretPositionint, clamped to the text length
InputFieldReadOnlyBinderreadOnlybool
InputFieldPlaceholderBinderplaceholderGraphic

InputFieldCommandBinder

Executes a command on the chosen field event (UpdateInputFieldEvent): an IRelayCommand without arguments or an IRelayCommand<string> with the text. The <T>, <T1, T2>, <T1, T2, T3> variants pass extra parameters after the text. InteractableMode works as in ButtonCommandBinder.


See also