From d859a315931d2b5a7a6d4630547bb849256ec56d Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Mon, 27 Nov 2023 13:24:01 +0900 Subject: [PATCH] [NUI] Add DispatchWheelEvents and DispatchPrentWheelEvents If DispatchWheelEvents sets false, view will not receive any WheelEvent including own. If DispatchPrentWheelEvents sets false, the parent view does not receive WheelEvent. --- .../src/public/BaseComponents/ViewEvent.cs | 95 +++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index 76bb039..a9814e2 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -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 } /// + /// 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. + /// + /// If the is a property that determines whether or not to be hittable, then this property prevents the propagation of the hit hover event. + /// + /// + [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; + } + + /// + /// 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. + /// + /// If the is a property that determines whether or not to be hittable, then this property prevents the propagation of the hit hover event. + /// + /// + [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; + } + + /// /// 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. -- 2.7.4