зеркало из https://github.com/DeGsoft/maui-linux.git
[Android] Forward ScrollView touch events to custom renderers (#472)
* Forward touch events * remove double cast
This commit is contained in:
Родитель
ceb09daf2d
Коммит
c9edd1a382
|
@ -31,6 +31,14 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
public override bool OnTouchEvent(MotionEvent ev)
|
||||
{
|
||||
// If the touch is caught by the horizontal scrollview, forward it to the parent so custom renderers can be notified of the touch.
|
||||
var verticalScrollViewerRenderer = Parent as ScrollViewRenderer;
|
||||
if (verticalScrollViewerRenderer != null)
|
||||
{
|
||||
verticalScrollViewerRenderer.ShouldSkipOnTouch = true;
|
||||
verticalScrollViewerRenderer.OnTouchEvent(ev);
|
||||
}
|
||||
|
||||
// The nested ScrollViews will allow us to scroll EITHER vertically OR horizontally in a single gesture.
|
||||
// This will allow us to also scroll diagonally.
|
||||
// We'll fall through to the base event so we still get the fling from the ScrollViews.
|
||||
|
@ -49,6 +57,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
ScrollBy((int)dX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnTouchEvent(ev);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
ScrollViewContainer _container;
|
||||
HorizontalScrollView _hScrollView;
|
||||
bool _isAttached;
|
||||
|
||||
internal bool ShouldSkipOnTouch;
|
||||
bool _isBidirectional;
|
||||
ScrollView _view;
|
||||
|
||||
|
@ -118,6 +118,12 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
public override bool OnTouchEvent(MotionEvent ev)
|
||||
{
|
||||
if (ShouldSkipOnTouch)
|
||||
{
|
||||
ShouldSkipOnTouch = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// The nested ScrollViews will allow us to scroll EITHER vertically OR horizontally in a single gesture.
|
||||
// This will allow us to also scroll diagonally.
|
||||
// We'll fall through to the base event so we still get the fling from the ScrollViews.
|
||||
|
|
Загрузка…
Ссылка в новой задаче