From 72543e1bc386f23f5d8f3f21068887ec16408fef Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Thu, 23 Jul 2009 15:29:45 -0400 Subject: Improvements to dragging on the WebTextView. When TextView handles a mouse move as a scroll, scroll the underlying textfield/textarea. Also do not hide the cursor while scrolling within a text input. Requires a change to external/webkit. --- core/java/android/webkit/WebTextView.java | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'core/java/android/webkit/WebTextView.java') diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 721f867f2458..7bc154b68857 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -78,7 +78,9 @@ import java.util.ArrayList; private float mDragStartY; private long mDragStartTime; private boolean mDragSent; - private boolean mPageScrolled; + // True if the most recent drag event has caused either the TextView to + // scroll or the web page to scroll. Gets reset after a touch down. + private boolean mScrolled; // Array to store the final character added in onTextChanged, so that its // KeyEvents may be determined. private char[] mCharacter = new char[1]; @@ -384,7 +386,7 @@ import java.util.ArrayList; mDragStartY = event.getY(); mDragStartTime = event.getEventTime(); mDragSent = false; - mPageScrolled = false; + mScrolled = false; break; case MotionEvent.ACTION_MOVE: Spannable buffer = getText(); @@ -393,8 +395,10 @@ import java.util.ArrayList; super.onTouchEvent(event); if (mScrollX != initialScrollX || mScrollY != initialScrollY) { - // TextView scrolled, so return true. - // FIXME: Need to make the webkit text scroll to reflect this + if (mWebView != null) { + mWebView.scrollFocusedTextInput(mScrollX, mScrollY); + } + mScrolled = true; return true; } if (mWebView != null) { @@ -406,7 +410,7 @@ import java.util.ArrayList; } boolean scrolled = mWebView.textFieldDrag(event); if (scrolled) { - mPageScrolled = true; + mScrolled = true; cancelLongPress(); return true; } @@ -414,12 +418,10 @@ import java.util.ArrayList; return false; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: - if (!mPageScrolled) { - // If the page scrolled, we do not want to change the selection, - // and the long press has already been canceled, so there is - // no need to call into super. - // FIXME: Once we enable scrolling the text inside the - // textfield, need to check that as well. + if (!mScrolled) { + // If the page scrolled, or the TextView scrolled, we do not + // want to change the selection, and the long press has already + // been canceled, so there is no need to call into super. super.onTouchEvent(event); } // Necessary for the WebView to reset its state -- cgit v1.2.3