[NUI] Checks the button area if GrabTouchAfterLeave is true.
authorjoogab.yun <joogab.yun@samsung.com>
Thu, 31 Mar 2022 03:26:37 +0000 (12:26 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 20 Apr 2022 08:38:08 +0000 (17:38 +0900)
If GrabTouchAfterLeave is true, Button Up will result in Finished rather than Interrupted even if it is out of the button area.

So, it is necessary to check whether it is Button Up in the button area.

src/Tizen.NUI.Components/Controls/Button.Internal.cs

index 70fe232..decaf67 100644 (file)
@@ -176,7 +176,7 @@ namespace Tizen.NUI.Components
                         }
 
                         ClickedEventArgs eventArgs = new ClickedEventArgs();
-                        OnClickedInternal(eventArgs);
+                        OnClickedInternal(eventArgs, touch);
 
                         return true;
                     }
@@ -454,6 +454,23 @@ namespace Tizen.NUI.Components
             }
         }
 
+        private void OnClickedInternal(ClickedEventArgs eventArgs, Touch touch)
+        {
+            // If GrabTouchAfterLeave is true, Up will result in Finished rather than Interrupted even if it is out of the button area.
+            // So, it is necessary to check whether it is Up in the button area.
+            if (GrabTouchAfterLeave == true)
+            {
+                Vector2 localPosition = touch.GetLocalPosition(0);
+                if ((localPosition != null && Size != null &&
+                    0 <= localPosition.X && localPosition.X <= Size.Width &&
+                    0 <= localPosition.Y && localPosition.Y <= Size.Height) == false)
+                {
+                    return;
+                }
+            }
+            OnClickedInternal(eventArgs);
+        }
+
         private void OnClickedInternal(ClickedEventArgs eventArgs)
         {
             Command?.Execute(CommandParameter);