[NUI] fix button IsEnabled and remove return value of OnEnabled
authorEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Thu, 17 Feb 2022 08:53:48 +0000 (00:53 -0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 22 Mar 2022 08:34:14 +0000 (17:34 +0900)
src/Tizen.NUI.Components/Controls/Button.Internal.cs
src/Tizen.NUI.Components/Controls/Button.cs
src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs

index 15e62a8..e61b52d 100644 (file)
@@ -186,6 +186,16 @@ namespace Tizen.NUI.Components
             return base.HandleControlStateOnTouch(touch);
         }
 
+
+        /// <inheritdoc/>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void OnEnabled(bool enabled)
+        {
+            base.OnEnabled(enabled);
+            //Sensitive = false;
+            UpdateState();
+        }
+
         /// <summary>
         /// Update Button State.
         /// </summary>
index ed9a3e6..ce2f576 100755 (executable)
@@ -66,23 +66,8 @@ namespace Tizen.NUI.Components
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
-        {
-            var instance = (Button)bindable;
-            if (newValue != null)
-            {
-                bool newEnabled = (bool)newValue;
-                if (instance.isEnabled != newEnabled)
-                {
-                    instance.isEnabled = newEnabled;
-                    // FIXME : InsEnabled Property should not change other property value.
-                    instance.Sensitive = newEnabled;
-                    ((Control)instance).IsEnabled = newEnabled;
-                    instance.UpdateState();
-                }
-            }
-        },
-        defaultValueCreator: (bindable) => ((Button)bindable).isEnabled);
+        public static readonly BindableProperty IsEnabledProperty = View.IsEnabledProperty;
+
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
@@ -183,7 +168,6 @@ namespace Tizen.NUI.Components
         private IconOrientation? iconRelativeOrientation = IconOrientation.Left;
         private bool isSelected = false;
         private bool isSelectable = false;
-        private bool isEnabled = true;
         private Size2D itemSpacing;
         private LinearLayout.Alignment itemAlignment = LinearLayout.Alignment.Center;
 
@@ -786,13 +770,10 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public bool IsEnabled
         {
-            get
-            {
-                return (bool)GetValue(IsEnabledProperty);
-            }
+            get => base.IsEnabled;
             set
             {
-                SetValue(IsEnabledProperty, value);
+                base.IsEnabled = value;
             }
         }
 
index ca72073..c7cf3a2 100755 (executable)
@@ -1174,8 +1174,8 @@ namespace Tizen.NUI.BaseComponents
             var view = (View)bindable;
             if (newValue != null)
             {
-                newValue = view.OnEnabled((bool)newValue);
                 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)view.SwigCPtr, View.Property.Enabled, new Tizen.NUI.PropertyValue((bool)newValue));
+                view.OnEnabled((bool)newValue);
             }
         }),
         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
index 9c870c0..1accd75 100755 (executable)
@@ -1275,7 +1275,7 @@ namespace Tizen.NUI.BaseComponents
         /// Inherited view can override this method to implements enabled property changes.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual bool OnEnabled(bool enabled)
+        protected virtual void OnEnabled(bool enabled)
         {
             if (enableControlState)
             {
@@ -1288,7 +1288,6 @@ namespace Tizen.NUI.BaseComponents
                     ControlState += ControlState.Disabled;
                 }
             }
-            return enabled;
         }