From: joogab.yun Date: Mon, 22 May 2023 05:21:06 +0000 (+0900) Subject: [NUI] Add DispatchParentTouchEvent X-Git-Tag: accepted/tizen/unified/20231205.024657~311 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbc17ddf4aac6e88b3ecaee0f32edc466edcc473;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add DispatchParentTouchEvent If a View's DispatchParentTouchEvents is set to false, then parents will not receive a touch event signal either. --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 3980341..872519a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -80,6 +80,7 @@ namespace Tizen.NUI.BaseComponents private RotationGestureDetector rotationGestureDetector = null; private int configGestureCount = 0; private bool dispatchTouchEvents = true; + private bool dispatchParentTouchEvents = true; private bool dispatchGestureEvents = true; private bool dispatchParentGestureEvents = true; private string internalName = string.Empty; @@ -3508,6 +3509,43 @@ namespace Tizen.NUI.BaseComponents } /// + /// Gets or sets the status of whether touch events can be dispatched to the parent. + /// If a View's DispatchParentTouchEvents is set to false, then parents will not receive a touch event signal either. + /// This works without adding a TouchEvent callback in the View. + /// + /// If the is a property that determines whether or not to be hittable, then this property prevents the propagation of the hit touch event. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool DispatchParentTouchEvents + { + get + { + return dispatchParentTouchEvents; + } + set + { + if (dispatchParentTouchEvents != value) + { + dispatchParentTouchEvents = value; + if (dispatchParentTouchEvents == false) + { + TouchEvent += OnDispatchParentTouchEvent; + } + else + { + TouchEvent -= OnDispatchParentTouchEvent; + } + } + } + } + + private bool OnDispatchParentTouchEvent(object source, View.TouchEventArgs e) + { + return true; + } + + /// /// Gets or sets the status of whether the view should emit Gesture event signals. /// If a View's DispatchGestureEvents is set to false, then itself and parents will not receive all gesture event signals. /// The itself and parents does not receive tap, pinch, pan, rotation, or longpress gestures. diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index 14aff55..97a4615 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -741,7 +741,7 @@ namespace Tizen.NUI.BaseComponents NUILog.Error("touchData should not be null!"); return true; } - + TouchEventArgs e = new TouchEventArgs(); e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData); return HitTest(e.Touch); @@ -807,6 +807,12 @@ namespace Tizen.NUI.BaseComponents consumed = HandleControlStateOnTouch(e.Touch); } + if (DispatchParentTouchEvents == false) + { + NUILog.Debug("If DispatchParentTouchEvents is false, it can not dispatch to parent."); + return true; + } + return consumed; }