From: Fang Xiaohui Date: Wed, 23 Mar 2022 03:09:34 +0000 (+0800) Subject: [NUI] Listen text changed event so that can notify binded instance when Text is chang... X-Git-Tag: submit/tizen_6.5/20220427.151219~1^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=637db9e1858e57848aa245449717479d2315d113;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Listen text changed event so that can notify binded instance when Text is changed by key input --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 3c86d87..37e9706 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -1843,28 +1843,32 @@ namespace Tizen.NUI.BaseComponents } } - /// Only used by the IL of xaml, will never changed to not hidden. - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool IsCreateByXaml + internal override bool IsBinded { get { - return base.IsCreateByXaml; + return base.IsBinded; } set { - base.IsCreateByXaml = value; + base.IsBinded = value; if (value == true) { - this.TextChanged += (obj, e) => - { - this.Text = e.TextEditor.Text; - }; + TextChanged += TextEditorTextChanged; + } + else + { + TextChanged -= TextEditorTextChanged; } } } + private void TextEditorTextChanged(object sender, TextChangedEventArgs e) + { + ForceNotifyBindedInstance(TextProperty); + } + /// /// The FontSizeScale property.
/// The default value is 1.0.
@@ -2115,6 +2119,11 @@ namespace Tizen.NUI.BaseComponents } } + if (IsBinded) + { + TextChanged -= TextEditorTextChanged; + } + base.Dispose(type); } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 3e74893..7c008a6 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -2017,28 +2017,32 @@ namespace Tizen.NUI.BaseComponents } } - /// Only used by the IL of xaml, will never changed to not hidden. - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool IsCreateByXaml + internal override bool IsBinded { get { - return base.IsCreateByXaml; + return base.IsBinded; } set { - base.IsCreateByXaml = value; + base.IsBinded = value; if (value == true) { - this.TextChanged += (obj, e) => - { - this.Text = e.TextField.Text; - }; + TextChanged += TextEditorTextChanged; + } + else + { + TextChanged -= TextEditorTextChanged; } } } + private void TextEditorTextChanged(object sender, TextChangedEventArgs e) + { + ForceNotifyBindedInstance(TextProperty); + } + /// /// Get the InputMethodContext instance. /// @@ -2161,6 +2165,11 @@ namespace Tizen.NUI.BaseComponents } } + if (IsBinded) + { + TextChanged -= TextEditorTextChanged; + } + base.Dispose(type); } diff --git a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs index 7897d25..c42b12c 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs @@ -209,19 +209,12 @@ namespace Tizen.NUI.Binding SetBinding(targetProperty, binding, false); } - private bool isCreateByXaml = false; /// Only used by the IL of xaml, will never changed to not hidden. [EditorBrowsable(EditorBrowsableState.Never)] - public virtual bool IsCreateByXaml + public bool IsCreateByXaml { - get - { - return isCreateByXaml; - } - set - { - isCreateByXaml = value; - } + get; + set; } /// @@ -286,6 +279,48 @@ namespace Tizen.NUI.Binding } } + /// This will be public opened in next ACR. + [EditorBrowsable(EditorBrowsableState.Never)] + public void ForceNotifyBindedInstance(BindableProperty property) + { + if (null != property) + { + BindablePropertyContext context = GetOrCreateContext(property); + + if (null != context?.Binding) + { + applying = true; + context.Binding.Apply(true); + applying = false; + } + + OnPropertyChanged(property.PropertyName); + + PropertyToGroup.TryGetValue(property, out HashSet propertyGroup); + + if (null != propertyGroup) + { + foreach (var relativeProperty in propertyGroup) + { + if (relativeProperty != property) + { + var relativeContext = GetOrCreateContext(relativeProperty); + var relativeBinding = relativeContext.Binding; + + if (null != relativeBinding) + { + applying = true; + relativeBinding.Apply(true); + applying = false; + } + + OnPropertyChanged(relativeProperty.PropertyName); + } + } + } + } + } + /// /// Sets the value of the propertyKey. /// @@ -736,7 +771,7 @@ namespace Tizen.NUI.Binding } } - internal bool IsBinded + internal virtual bool IsBinded { get; set;