protected override void OnAttached() { effect = TouchEffect.PickFrom(Element); if (effect == null || effect.IsDisabled) { return; } effect.Element = (VisualElement)Element; if (effect.NativeAnimation) { var nativeControl = Container; if (string.IsNullOrEmpty(nativeControl.Name)) { nativeControl.Name = Guid.NewGuid().ToString(); } if (nativeControl.Resources.ContainsKey(pointerDownAnimationKey)) { pointerDownStoryboard = (Storyboard)nativeControl.Resources[pointerDownAnimationKey]; } else { pointerDownStoryboard = new Storyboard(); var downThemeAnimation = new PointerDownThemeAnimation(); Storyboard.SetTargetName(downThemeAnimation, nativeControl.Name); pointerDownStoryboard.Children.Add(downThemeAnimation); nativeControl.Resources.Add(new KeyValuePair <object, object>(pointerDownAnimationKey, pointerDownStoryboard)); } if (nativeControl.Resources.ContainsKey(pointerUpAnimationKey)) { pointerUpStoryboard = (Storyboard)nativeControl.Resources[pointerUpAnimationKey]; } else { pointerUpStoryboard = new Storyboard(); var upThemeAnimation = new PointerUpThemeAnimation(); Storyboard.SetTargetName(upThemeAnimation, nativeControl.Name); pointerUpStoryboard.Children.Add(upThemeAnimation); nativeControl.Resources.Add(new KeyValuePair <object, object>(pointerUpAnimationKey, pointerUpStoryboard)); } } if (Container != null) { Container.PointerPressed += OnPointerPressed; Container.PointerReleased += OnPointerReleased; Container.PointerCanceled += OnPointerCanceled; Container.PointerExited += OnPointerExited; Container.PointerEntered += OnPointerEntered; Container.PointerCaptureLost += OnPointerCaptureLost; } }
protected override void OnAttached() { effect = TouchEffect.PickFrom(Element); if (effect?.IsDisabled ?? true) { return; } effect.Element = (VisualElement)Element; if (View == null) { return; } touchGesture = new TouchUITapGestureRecognizer(effect); if (((View as IVisualNativeElementRenderer)?.Control ?? View) is UIButton button) { button.AllTouchEvents += PreventButtonHighlight; ((TouchUITapGestureRecognizer)touchGesture).IsButton = true; } View.AddGestureRecognizer(touchGesture); if (XCT.IsiOS13OrNewer) { hoverGesture = new UIHoverGestureRecognizer(OnHover); View.AddGestureRecognizer(hoverGesture); } View.UserInteractionEnabled = true; }
protected override void OnDetached() { if (effect?.Element == null) { return; } if (((View as IVisualNativeElementRenderer)?.Control ?? View) is UIButton button) { button.AllTouchEvents -= PreventButtonHighlight; } if (touchGesture != null) { View?.RemoveGestureRecognizer(touchGesture); touchGesture?.Dispose(); touchGesture = null; } if (hoverGesture != null) { View?.RemoveGestureRecognizer(hoverGesture); hoverGesture?.Dispose(); hoverGesture = null; } effect.Element = null; effect = null; }
protected override void OnAttached() { if (View == null) { return; } effect = TouchEffect.PickFrom(Element); if (effect?.IsDisabled ?? true) { return; } effect.Element = (VisualElement)Element; View.Touch += OnTouch; UpdateClickHandler(); accessibilityManager = View.Context?.GetSystemService(Context.AccessibilityService) as AccessibilityManager; if (accessibilityManager != null) { accessibilityListener = new AccessibilityListener(this); accessibilityManager.AddAccessibilityStateChangeListener(accessibilityListener); accessibilityManager.AddTouchExplorationStateChangeListener(accessibilityListener); } if (XCT.SdkInt < (int)BuildVersionCodes.Lollipop || !effect.NativeAnimation) { return; } View.Clickable = true; View.LongClickable = true; CreateRipple(); if (Group == null) { if (XCT.SdkInt >= (int)BuildVersionCodes.M) { View.Foreground = ripple; } return; } rippleView = new FrameLayout(Group.Context ?? throw new NullReferenceException()) { LayoutParameters = new ViewGroup.LayoutParams(-1, -1), Clickable = false, Focusable = false, Enabled = false, }; View.LayoutChange += OnLayoutChange; rippleView.Background = ripple; Group.AddView(rippleView); rippleView.BringToFront(); }
protected override void Dispose(bool disposing) { if (disposing) { effect = null; container = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { effect = null; Delegate.Dispose(); } base.Dispose(disposing); }
protected override void OnAttached() { effect = TouchEffect.PickFrom(Element); if (effect?.IsDisabled ?? true) { return; } effect.Element = (VisualElement)Element; gestureLayer = new TouchTapGestureRecognizer(Control, effect); }
protected override void OnDetached() { if (effect?.Element == null) { return; } try { if (accessibilityManager != null && accessibilityListener != null) { accessibilityManager.RemoveAccessibilityStateChangeListener(accessibilityListener); accessibilityManager.RemoveTouchExplorationStateChangeListener(accessibilityListener); accessibilityListener.Dispose(); accessibilityManager = null; accessibilityListener = null; } if (View != null) { View.LayoutChange -= OnLayoutChange; View.Touch -= OnTouch; View.Click -= OnClick; if (XCT.SdkInt >= (int)BuildVersionCodes.M && View.Foreground == ripple) { View.Foreground = null; } } effect.Element = null; effect = null; if (rippleView != null) { rippleView.Pressed = false; rippleView.Background = null; Group?.RemoveView(rippleView); rippleView.Dispose(); rippleView = null; } ripple?.Dispose(); ripple = null; } catch (ObjectDisposedException) { // Suppress exception } isHoverSupported = false; }
protected override void Dispose(bool disposing) { if (disposing) { if (trackingArea != null) { RemoveTrackingArea(trackingArea); trackingArea.Dispose(); } effect = null; } base.Dispose(disposing); }
protected override void OnDetached() { if (effect?.Element == null) { return; } if (gestureLayer != null) { gestureLayer.ClearCallbacks(); gestureLayer.Unrealize(); gestureLayer = null; } effect.Element = null; effect = null; }
protected override void OnAttached() { effect = TouchEffect.PickFrom(Element); if (effect?.IsDisabled ?? true) { return; } effect.Element = (VisualElement)Element; if (Container != null) { gesture = new TouchNSClickGestureRecognizer(effect, Container); Container.AddGestureRecognizer(gesture); Container.AddSubview(mouseTrackingView = new MouseTrackingView(effect)); } }
protected override void OnDetached() { if (effect?.Element == null) { return; } try { if (accessibilityManager != null && accessibilityListener != null) { accessibilityManager.RemoveAccessibilityStateChangeListener(accessibilityListener); accessibilityManager.RemoveTouchExplorationStateChangeListener(accessibilityListener); accessibilityListener.Dispose(); accessibilityManager = null; accessibilityListener = null; } RemoveRipple(); if (View != null) { View.LayoutChange -= OnLayoutChange; View.Touch -= OnTouch; View.Click -= OnClick; } effect.Element = null; effect = null; if (rippleView != null) { rippleView.Pressed = false; Group?.RemoveView(rippleView); rippleView.Dispose(); rippleView = null; } } catch (ObjectDisposedException) { // Suppress exception } isHoverSupported = false; }
protected override void OnDetached() { if (effect?.Element == null) { return; } mouseTrackingView?.RemoveFromSuperview(); mouseTrackingView?.Dispose(); mouseTrackingView = null; effect.Element = null; effect = null; if (gesture != null) { Container?.RemoveGestureRecognizer(gesture); gesture.Dispose(); } gesture = null; }
protected override void OnDetached() { if (effect?.Element == null) { return; } effect.Element = null; effect = null; if (Container != null) { Container.PointerPressed -= OnPointerPressed; Container.PointerReleased -= OnPointerReleased; Container.PointerCanceled -= OnPointerCanceled; Container.PointerExited -= OnPointerExited; Container.PointerEntered -= OnPointerEntered; Container.PointerCaptureLost -= OnPointerCaptureLost; isPressed = false; } }
protected override void OnAttached() { if (View == null) { return; } effect = TouchEffect.PickFrom(Element); if (effect?.IsDisabled ?? true) { return; } effect.Element = (VisualElement)Element; View.Touch += OnTouch; UpdateClickHandler(); accessibilityManager = View.Context?.GetSystemService(Context.AccessibilityService) as AccessibilityManager; if (accessibilityManager != null) { accessibilityListener = new AccessibilityListener(this); accessibilityManager.AddAccessibilityStateChangeListener(accessibilityListener); accessibilityManager.AddTouchExplorationStateChangeListener(accessibilityListener); } if (XCT.SdkInt < (int)BuildVersionCodes.Lollipop || !effect.NativeAnimation) { return; } View.Clickable = true; View.LongClickable = true; CreateRipple(); ApplyRipple(); View.LayoutChange += OnLayoutChange; }
void CheckForBoundaryHop(int id, Point pointerLocation) { TouchEffect?touchEffectHit = null; foreach (Android.Views.View view in _viewDictionary.Keys) { // Get the view rectangle try { view.GetLocationOnScreen(_twoIntArray); } catch // System.ObjectDisposedException: Cannot access a disposed object. { continue; } Rectangle viewRect = new Rectangle(_twoIntArray[0], _twoIntArray[1], view.Width, view.Height); if (viewRect.Contains(pointerLocation)) { touchEffectHit = _viewDictionary[view]; } } if (touchEffectHit != _idToEffectDictionary[id]) { if (_idToEffectDictionary[id] != null) { FireEvent(_idToEffectDictionary[id], id, TouchActionType.Exited, pointerLocation, true); } if (touchEffectHit != null) { FireEvent(touchEffectHit, id, TouchActionType.Entered, pointerLocation, true); } _idToEffectDictionary[id] = touchEffectHit !; } }
public TouchNSClickGestureRecognizer(TouchEffect effect, NSView container) { this.effect = effect; this.container = container; }
public MouseTrackingView(TouchEffect effect) { this.effect = effect; AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; }
public TouchTapGestureRecognizer(EvasObject parent, TouchEffect effect) : this(parent) { Attach(parent); this.effect = effect; }
public TouchUITapGestureRecognizer(TouchEffect effect) { this.effect = effect; CancelsTouchesInView = false; Delegate = new TouchUITapGestureRecognizerDelegate(); }