[NUI] Add DispatchWheelEvents and DispatchPrentWheelEvents
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 27 Nov 2023 04:24:01 +0000 (13:24 +0900)
committerhuiyu <35286162+huiyueun@users.noreply.github.com>
Wed, 29 Nov 2023 05:55:25 +0000 (14:55 +0900)
If DispatchWheelEvents sets false, view will not receive any WheelEvent including own.
If DispatchPrentWheelEvents sets false, the parent view does not receive WheelEvent.

src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs

index 76bb039..a9814e2 100755 (executable)
@@ -102,6 +102,8 @@ namespace Tizen.NUI.BaseComponents
         private bool dispatchParentTouchEvents = true;
         private bool dispatchHoverEvents = true;
         private bool dispatchParentHoverEvents = true;
+        private bool dispatchWheelEvents = true;
+        private bool dispatchParentWheelEvents = true;
         private bool dispatchGestureEvents = true;
         private bool dispatchParentGestureEvents = true;
 
@@ -961,15 +963,30 @@ namespace Tizen.NUI.BaseComponents
                 return true;
             }
 
+            if (DispatchWheelEvents == false)
+            {
+                NUILog.Debug("If DispatchWheelEvents is false, it can not dispatch.");
+                return true;
+            }
+
             WheelEventArgs e = new WheelEventArgs();
 
             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
 
+            bool consumed = false;
+
             if (wheelEventHandler != null)
             {
-                return wheelEventHandler(this, e);
+                consumed = wheelEventHandler(this, e);
+            }
+
+            if (DispatchParentWheelEvents == false && consumed == false)
+            {
+                NUILog.Debug("If DispatchParentWheelEvents is false, it can not dispatch to parent.");
+                return true;
             }
-            return false;
+
+            return consumed;
         }
 
         // Callback for View OnWindow signal
@@ -1553,6 +1570,80 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Gets or sets the status of whether wheel events can be dispatched.
+        /// If a View's DispatchWheelEvents is set to false, then it's can not will receive wheel event and parents will not receive a wheel event signal either.
+        /// This works without adding a WheelEvent callback in the View.
+        /// <note>
+        /// If the <see cref="Tizen.NUI.BaseComponents.View.Sensitive"/> is a property that determines whether or not to be hittable, then this property prevents the propagation of the hit hover event.
+        /// </note>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool DispatchWheelEvents
+        {
+            get
+            {
+                return dispatchWheelEvents;
+            }
+            set
+            {
+                if (dispatchWheelEvents != value)
+                {
+                    dispatchWheelEvents = value;
+                    if (dispatchWheelEvents == false)
+                    {
+                        WheelEvent += OnDispatchWheelEvent;
+                    }
+                    else
+                    {
+                        WheelEvent -= OnDispatchWheelEvent;
+                    }
+                }
+            }
+        }
+
+        private bool OnDispatchWheelEvent(object source, View.WheelEventArgs e)
+        {
+            return true;
+        }
+
+        /// <summary>
+        /// Gets or sets the status of whether wheel events can be dispatched to the parent.
+        /// If a View's DispatchParentWheelEvents is set to false, then parents will not receive a wheel event signal either.
+        /// This works without adding a WheelEvent callback in the View.
+        /// <note>
+        /// If the <see cref="Tizen.NUI.BaseComponents.View.Sensitive"/> is a property that determines whether or not to be hittable, then this property prevents the propagation of the hit hover event.
+        /// </note>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool DispatchParentWheelEvents
+        {
+            get
+            {
+                return dispatchParentWheelEvents;
+            }
+            set
+            {
+                if (dispatchParentWheelEvents != value)
+                {
+                    dispatchParentWheelEvents = value;
+                    if (dispatchParentWheelEvents == false)
+                    {
+                        WheelEvent += OnDispatchParentWheelEvent;
+                    }
+                    else
+                    {
+                        WheelEvent -= OnDispatchParentWheelEvent;
+                    }
+                }
+            }
+        }
+
+        private bool OnDispatchParentWheelEvent(object source, View.WheelEventArgs e)
+        {
+            return true;
+        }
+
+        /// <summary>
         /// 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.