[NUI] Add DisallowInterceptTouchEvent (#2109)
authorJoogabYun <40262755+JoogabYun@users.noreply.github.com>
Thu, 29 Oct 2020 06:52:38 +0000 (15:52 +0900)
committerGitHub <noreply@github.com>
Thu, 29 Oct 2020 06:52:38 +0000 (15:52 +0900)
If child view doesn't want the parent's view to intercept the touch, you can set it to true.
 for example :
    parent.Add(child);
    parent.InterceptTouchEvent += OnInterceptTouchEvent;
    View view = child.GetParent() as View;
    view.DisallowInterceptTouchEvent = true;
 This prevents the parent from interceping touch.

Co-authored-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs

index 2e89367..62513e7 100755 (executable)
@@ -252,6 +252,19 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
+        /// for example :
+        ///    parent.Add(child);
+        ///    parent.InterceptTouchEvent += OnInterceptTouchEvent;
+        ///    View view = child.GetParent() as View;
+        ///    view.DisallowInterceptTouchEvent = true;
+        ///  This prevents the parent from interceping touch.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool DisallowInterceptTouchEvent {get; set;}
+
+
+        /// <summary>
         /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
         /// The touched signal is emitted when the touch input is received.<br />
         /// </summary>
@@ -812,6 +825,12 @@ namespace Tizen.NUI.BaseComponents
                 return true;
             }
 
+            // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
+            if (DisallowInterceptTouchEvent)
+            {
+                return false;
+            }
+
             TouchEventArgs e = new TouchEventArgs();
 
             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
@@ -823,11 +842,6 @@ namespace Tizen.NUI.BaseComponents
                 consumed = _interceptTouchDataEventHandler(this, e);
             }
 
-            if (enableControlState && !consumed)
-            {
-                consumed = HandleControlStateOnTouch(e.Touch);
-            }
-
             return consumed;
         }