public bool HandleMotionEvent(IViewParent parent, MotionEvent motionEvent) { if (_isInViewCell || _element.InputTransparent || motionEvent.Action == MotionEventActions.Cancel) { return(false); } var renderer = parent as VisualElementRenderer <Xamarin.Forms.View>; if (renderer == null) { return(false); } var type = parent.GetType(); if (type.Name.Contains("DefaultRenderer")) { try { // Let the container know that we're "fake" handling this event var method = type.GetTypeInfo().GetDeclaredMethod("NotifyFakeHandling"); if (method != null) { method.Invoke(parent, null); return(true); } } catch (Exception) { } } return(true); }
public bool HandleMotionEvent(IViewParent parent, MotionEvent motionEvent) { if (_isInViewCell || _element.InputTransparent || motionEvent.Action == MotionEventActions.Cancel) { return(false); } var rendererType = parent.GetType(); if (!_platformDefaultRendererType.IsAssignableFrom(rendererType)) { return(false); } try { // Let the container know that we're "fake" handling this event if (_platformDefaultRendererTypeNotifyFakeHandling != null) { _platformDefaultRendererTypeNotifyFakeHandling.Invoke(parent, null); return(true); } } catch { } return(false); }
public bool RequestFocus(global::Android.Views.View control, Func <bool> baseRequestFocus) { IViewParent ancestor = control.Parent; var previousFocusability = DescendantFocusability.BlockDescendants; LinearLayout cfl = null; // Work our way up through the tree until we find a ConditionalFocusLayout while (ancestor is ViewGroup) { cfl = ancestor as LinearLayout; var found = ancestor.GetType().Name == "ConditionalFocusLayout"; if (cfl != null && found) { previousFocusability = cfl.DescendantFocusability; // Toggle DescendantFocusability to allow this control to get focus cfl.DescendantFocusability = DescendantFocusability.AfterDescendants; break; } ancestor = ancestor.Parent; } // Call the original RequestFocus implementation for the View bool result = baseRequestFocus(); if (cfl != null) { // Toggle descendantfocusability back to whatever it was cfl.DescendantFocusability = previousFocusability; } return(result); }