From 57f4e5bcf56752053815a755fee4867e722ce2b8 Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Mon, 21 Jun 2010 16:21:51 -0700 Subject: [PATCH] Fixed scrolling issue when moving cursor in long TextViews. Previous CL https://android-git.corp.google.com/g/55138 was submitted before the suggested change was uploaded. setSelection() was called twice by onTouchEvent, once to the previous position, and then to the new position (unless the IME got displayed, so that in that case the cursor is not moved). The second call was actually triggering a call for a scroll of 0 since the view is already displaying the cursor. This scroll is filtered out by a shortcut in ScrollView. The first setSelection's scroll does not have the same issue (since the previous cursor's position is out of screen and requires a scroll) and it is then applied, effectively moving the cursor to a new position but scrolling to the previous position. The fix is to call setSelection only once, after the IME has been asked to display. The cursor is moved to the old/new position depending on the resultCode in onReceiveResult in CommitSelectionReceiver. Bug: http://b/issue?id=2778954 Change-Id: I157d7ae451574e8a6fffb894eb1d6880acfe01d1 --- core/java/android/widget/TextView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index e0f766d755b0d..de0a84691dcfd 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -5663,7 +5663,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * one character (a selection range). This will only work if the * TextView contains spannable text; otherwise it will do nothing. * - * @return True is the cursor was actually moved, false otherwise. + * @return True if the cursor was actually moved, false otherwise. */ public boolean moveCursorToVisibleOffset() { if (!(mText instanceof Spannable)) {