From 89e0c62a1dd618c0c2011fa765a43ec901f7536e Mon Sep 17 00:00:00 2001 From: Xianbing Teng Date: Fri, 20 Jul 2018 18:21:54 +0800 Subject: [PATCH] Fix controls created by xaml issues (#341) --- .../src/internal/Xaml/CreateValuesVisitor.cs | 6 ++--- .../src/public/BaseComponents/TextEditor.cs | 22 ++++++++++++++--- .../src/public/BaseComponents/TextField.cs | 23 +++++++++++++++--- .../src/public/UIComponents/PushButton.cs | 28 +++++++++++++++++----- src/Tizen.NUI/src/public/UIComponents/Slider.cs | 23 ++++++++++++++---- .../src/public/XamlBinding/BindableObject.cs | 13 +++++++++- .../src/public/XamlBinding/ContentPage.cs | 2 +- 7 files changed, 96 insertions(+), 21 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs index 0dc695a..7d168b9 100755 --- a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs @@ -90,7 +90,7 @@ namespace Tizen.NUI.Xaml value = Activator.CreateInstance(type); if (value is BindableObject) { - ((BindableObject)value).isCreateByXaml = true; + ((BindableObject)value).IsCreateByXaml = true; } } } @@ -202,7 +202,7 @@ namespace Tizen.NUI.Xaml object ret = Activator.CreateInstance(nodeType, arguments); if (ret is BindableObject) { - ((BindableObject)ret).isCreateByXaml = true; + ((BindableObject)ret).IsCreateByXaml = true; } return ret; } @@ -306,7 +306,7 @@ namespace Tizen.NUI.Xaml value = Activator.CreateInstance(nodeType); if (value is BindableObject) { - ((BindableObject)value).isCreateByXaml = true; + ((BindableObject)value).IsCreateByXaml = true; } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index f442e56..545eb36 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -1217,10 +1217,26 @@ namespace Tizen.NUI.BaseComponents public TextEditor() : this(NDalicPINVOKE.TextEditor_New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - this.TextChanged += (obj, e) => + } + + internal override bool IsCreateByXaml + { + get { - this.Text = this.Text; - }; + return base.IsCreateByXaml; + } + set + { + base.IsCreateByXaml = value; + + if (value == true) + { + this.TextChanged += (obj, e) => + { + this.Text = this.Text; + }; + } + } } internal TextEditor(TextEditor handle) : this(NDalicPINVOKE.new_TextEditor__SWIG_1(TextEditor.getCPtr(handle)), true) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index d77f8b7..f62a203 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -1256,9 +1256,26 @@ namespace Tizen.NUI.BaseComponents public TextField() : this(NDalicPINVOKE.TextField_New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - this.TextChanged += (obj, e) => { - this.Text = this.Text; - }; + } + + internal override bool IsCreateByXaml + { + get + { + return base.IsCreateByXaml; + } + set + { + base.IsCreateByXaml = value; + + if (value == true) + { + this.TextChanged += (obj, e) => + { + this.Text = this.Text; + }; + } + } } internal TextField(TextField handle) : this(NDalicPINVOKE.new_TextField__SWIG_1(TextField.getCPtr(handle)), true) diff --git a/src/Tizen.NUI/src/public/UIComponents/PushButton.cs b/src/Tizen.NUI/src/public/UIComponents/PushButton.cs index e694d84..4c47db0 100755 --- a/src/Tizen.NUI/src/public/UIComponents/PushButton.cs +++ b/src/Tizen.NUI/src/public/UIComponents/PushButton.cs @@ -103,15 +103,31 @@ namespace Tizen.NUI.UIComponents public PushButton() : this(NDalicPINVOKE.PushButton_New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - this.Clicked += (sender, e) => + } + + internal override bool IsCreateByXaml + { + get { - ICommand command = this.Command; - if (command != null) + return base.IsCreateByXaml; + } + set + { + base.IsCreateByXaml = value; + + if (value == true) { - command.Execute(this.CommandParameter); + this.Clicked += (sender, e) => + { + ICommand command = this.Command; + if (command != null) + { + command.Execute(this.CommandParameter); + } + return true; + }; } - return true; - }; + } } /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. diff --git a/src/Tizen.NUI/src/public/UIComponents/Slider.cs b/src/Tizen.NUI/src/public/UIComponents/Slider.cs index 89de3c0..59eef13 100755 --- a/src/Tizen.NUI/src/public/UIComponents/Slider.cs +++ b/src/Tizen.NUI/src/public/UIComponents/Slider.cs @@ -757,11 +757,26 @@ namespace Tizen.NUI.UIComponents public Slider() : this(NDalicPINVOKE.Slider_New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } - this.ValueChanged += (obj, e) => { - this.Value = e.SlideValue; - return true; - }; + internal override bool IsCreateByXaml + { + get + { + return base.IsCreateByXaml; + } + set + { + base.IsCreateByXaml = value; + + if (value == true) + { + this.ValueChanged += (obj, e) => { + this.Value = e.SlideValue; + return true; + }; + } + } } internal Slider(Slider handle) : this(NDalicPINVOKE.new_Slider__SWIG_1(Slider.getCPtr(handle)), true) diff --git a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs index 92f20d8..5d24e1b 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs @@ -148,7 +148,18 @@ namespace Tizen.NUI.Binding SetBinding(targetProperty, binding, false); } - internal bool isCreateByXaml = false; + private bool isCreateByXaml = false; + internal virtual bool IsCreateByXaml + { + get + { + return isCreateByXaml; + } + set + { + isCreateByXaml = value; + } + } /// /// Sets the value of the specified property. diff --git a/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs b/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs index a7faadc..3a31e72 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs @@ -113,7 +113,7 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public ContentPage(Window win) { - isCreateByXaml = true; + IsCreateByXaml = true; Root = new View(); Root.WidthResizePolicy = ResizePolicyType.FillToParent; -- 2.7.4