private UIElement GetReactViewTarget(DependencyObject originalSource, Point point) { // If the target is not a child of the root view, then this pointer // event does not belong to React. if (!RootViewHelper.IsReactSubview(originalSource)) { return null; } // population of sources provided by: // http://stackoverflow.com/questions/2059475/what-is-the-silverlights-findelementsinhostcoordinates-equivalent-in-wpf var sources = new List<DependencyObject>(); //changed from external edits, because VisualHit is //only a DependencyObject and may not be a UIElement //this could cause exceptions or may not be compiling at all //simply filter the result for class UIElement and //cast it to IEnumerable<UIElement> if you need //the very exact same result including type VisualTreeHelper.HitTest( _view, null, new HitTestResultCallback( hit => { var source = hit.VisualHit; if (!source.HasTag()) { return HitTestResultBehavior.Continue; } var pointerEvents = source.GetPointerEvents(); if (pointerEvents == PointerEvents.None || pointerEvents == PointerEvents.BoxNone) { return HitTestResultBehavior.Continue; } sources.Add(hit.VisualHit); return HitTestResultBehavior.Continue; }), new PointHitTestParameters(point)); // Get the first React view that does not have pointer events set // to 'none' or 'box-none', and is not a child of a view with // 'box-only' or 'none' settings for pointer events. // TODO: use pooled data structure var isBoxOnlyCache = new Dictionary<DependencyObject, bool>(); foreach (var source in sources) { var viewHierarchy = RootViewHelper.GetReactViewHierarchy(source); var isBoxOnly = IsBoxOnlyWithCache(viewHierarchy, isBoxOnlyCache); if (!isBoxOnly) { return (UIElement)source; } } return null; }
private UIElement GetReactViewTarget(DependencyObject originalSource, Point point) { // If the target is not a child of the root view, then this pointer // event does not belong to React. if (!RootViewHelper.IsReactSubview(originalSource)) { return(null); } var adjustedPoint = AdjustPointForStatusBar(point); var sources = VisualTreeHelper.FindElementsInHostCoordinates(adjustedPoint, _view); // Get the first React view that does not have pointer events set // to 'none' or 'box-none', and is not a child of a view with // 'box-only' or 'none' settings for pointer events. // TODO: use pooled data structure var isBoxOnlyCache = new Dictionary <DependencyObject, bool>(); foreach (var source in sources) { if (!source.HasTag()) { continue; } var pointerEvents = source.GetPointerEvents(); if (pointerEvents == PointerEvents.None || pointerEvents == PointerEvents.BoxNone) { continue; } var viewHierarchy = RootViewHelper.GetReactViewHierarchy(source); var isBoxOnly = IsBoxOnlyWithCache(viewHierarchy, isBoxOnlyCache); if (!isBoxOnly) { return(source); } } return(null); }
private static bool ShouldSendEnterLeaveEvent(DependencyObject view) { // If the target is not a child of the root view, then this pointer // event does not belong to React. if (!RootViewHelper.IsReactSubview(view)) { return false; } var viewHierarchy = RootViewHelper.GetReactViewHierarchy(view); foreach (var ancestor in viewHierarchy) { var pointerEvents = ancestor.GetPointerEvents(); if (pointerEvents == PointerEvents.None || pointerEvents == PointerEvents.BoxNone) { return false; } } return true; }
private UIElement GetReactViewTarget(DependencyObject originalSource, Point point) { // If the target is not a child of the root view, then this pointer // event does not belong to React. if (!RootViewHelper.IsReactSubview(originalSource)) { return(null); } // population of sources provided by: // http://stackoverflow.com/questions/2059475/what-is-the-silverlights-findelementsinhostcoordinates-equivalent-in-wpf var sources = new List <DependencyObject>(); //changed from external edits, because VisualHit is //only a DependencyObject and may not be a UIElement //this could cause exceptions or may not be compiling at all //simply filter the result for class UIElement and //cast it to IEnumerable<UIElement> if you need //the very exact same result including type VisualTreeHelper.HitTest( _view, null, new HitTestResultCallback( hit => { var source = hit.VisualHit; if (!source.HasTag()) { return(HitTestResultBehavior.Continue); } var pointerEvents = source.GetPointerEvents(); if (pointerEvents == PointerEvents.None || pointerEvents == PointerEvents.BoxNone) { return(HitTestResultBehavior.Continue); } sources.Add(hit.VisualHit); return(HitTestResultBehavior.Continue); }), new PointHitTestParameters(point)); var viewHierarchy = RootViewHelper.GetReactViewHierarchy(originalSource); var dependencyObjects = viewHierarchy as DependencyObject[] ?? viewHierarchy.ToArray(); var enumerator = dependencyObjects.GetEnumerator(); if (!enumerator.MoveNext()) { return(null); } if (enumerator.Current.GetPointerEvents() == PointerEvents.BoxNone) { var nonBoxOnlyView = sources.FirstOrDefault(x => x.HasTag() && x.GetPointerEvents() != PointerEvents.BoxNone); enumerator = RootViewHelper.GetReactViewHierarchy(nonBoxOnlyView).GetEnumerator(); if (!enumerator.MoveNext()) { return(null); } } var element = enumerator.Current; while (enumerator.MoveNext()) { var current = enumerator.Current; if (element == null || current.GetPointerEvents() == PointerEvents.BoxOnly || !(element is UIElement)) { element = current; } } return((UIElement)element); }