diff options
author | Leon Scroggins <scroggo@google.com> | 2009-09-16 14:12:52 -0400 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2009-09-16 14:24:08 -0400 |
commit | 7ae34197b03313dd3f278b1a995252040ae6e2df (patch) | |
tree | cfb06530656f67bdc6d9da72845ed6d7f54f44d9 /core | |
parent | 4f8bb4c8a0ec6fa89857281537ad0c5d12bcff47 (diff) | |
download | frameworks_base-7ae34197b03313dd3f278b1a995252040ae6e2df.zip frameworks_base-7ae34197b03313dd3f278b1a995252040ae6e2df.tar.gz frameworks_base-7ae34197b03313dd3f278b1a995252040ae6e2df.tar.bz2 |
Allow touches to change the selection in WebTextView.
Fix http://b/issue?id=2019857
If the user has not moved beyond the scaled touch slop, do not
turn it into a scroll, so the user can change the selection.
Change-Id: I1d88691a35ea2da4b03ad713b56331b5c268b757
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/webkit/WebTextView.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 95b3a12..a175be0 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -38,6 +38,7 @@ import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; @@ -430,18 +431,26 @@ import java.util.ArrayList; mGotTouchDown = true; break; case MotionEvent.ACTION_MOVE: + int slop = ViewConfiguration.get(mContext).getScaledTouchSlop(); Spannable buffer = getText(); int initialScrollX = Touch.getInitialScrollX(this, buffer); int initialScrollY = Touch.getInitialScrollY(this, buffer); super.onTouchEvent(event); - if (mScrollX != initialScrollX - || mScrollY != initialScrollY) { + if (Math.abs(mScrollX - initialScrollX) > slop + || Math.abs(mScrollY - initialScrollY) > slop) { if (mWebView != null) { mWebView.scrollFocusedTextInput(mScrollX, mScrollY); } mScrolled = true; return true; } + if (Math.abs((int) event.getX() - mDragStartX) < slop + && Math.abs((int) event.getY() - mDragStartY) < slop) { + // If the user has not scrolled further than slop, we should not + // send the drag. Instead, do nothing, and when the user lifts + // their finger, we will change the selection. + return true; + } if (mWebView != null) { // Only want to set the initial state once. if (!mDragSent) { |