public virtual bool onGenericMotionEvent(android.widget.TextView widget, android.text.Spannable text, android.view.MotionEvent @event) { if ((@event.getSource() & android.view.InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (@event.getAction()) { case android.view.MotionEvent.ACTION_SCROLL: { float vscroll; float hscroll; if ((@event.getMetaState() & android.view.KeyEvent.META_SHIFT_ON) != 0) { vscroll = 0; hscroll = @event.getAxisValue(android.view.MotionEvent.AXIS_VSCROLL); } else { vscroll = [email protected](android.view.MotionEvent.AXIS_VSCROLL); hscroll = @event.getAxisValue(android.view.MotionEvent.AXIS_HSCROLL); } bool handled = false; if (hscroll < 0) { handled |= scrollLeft(widget, text, (int)System.Math.Ceiling(-hscroll)); } else { if (hscroll > 0) { handled |= scrollRight(widget, text, (int)System.Math.Ceiling(hscroll)); } } if (vscroll < 0) { handled |= scrollUp(widget, text, (int)System.Math.Ceiling(-vscroll)); } else { if (vscroll > 0) { handled |= scrollDown(widget, text, (int)System.Math.Ceiling(vscroll)); } } return handled; } } } return false; }
public override bool onTouchEvent(android.view.MotionEvent @event) { if (!mIsUserSeekable || !isEnabled()) { return(false); } switch (@event.getAction()) { case android.view.MotionEvent.ACTION_DOWN: { if (isInScrollingContainer()) { mTouchDownX = @event.getX(); } else { setPressed(true); if (mThumb != null) { invalidate(mThumb.getBounds()); } // This may be within the padding region onStartTrackingTouch(); trackTouchEvent(@event); attemptClaimDrag(); } break; } case android.view.MotionEvent.ACTION_MOVE: { if (mIsDragging) { trackTouchEvent(@event); } else { float x = @event.getX(); if (System.Math.Abs(x - mTouchDownX) > mScaledTouchSlop) { setPressed(true); if (mThumb != null) { invalidate(mThumb.getBounds()); } // This may be within the padding region onStartTrackingTouch(); trackTouchEvent(@event); attemptClaimDrag(); } } break; } case android.view.MotionEvent.ACTION_UP: { if (mIsDragging) { trackTouchEvent(@event); onStopTrackingTouch(); setPressed(false); } else { // Touch up when we never crossed the touch slop threshold should // be interpreted as a tap-seek to that location. onStartTrackingTouch(); trackTouchEvent(@event); onStopTrackingTouch(); } // ProgressBar doesn't know to repaint the thumb drawable // in its inactive state when the touch stops (because the // value has not apparently changed) invalidate(); break; } case android.view.MotionEvent.ACTION_CANCEL: { if (mIsDragging) { onStopTrackingTouch(); setPressed(false); } invalidate(); // see above explanation break; } } return(true); }