diff options
author | Gilles Debunne <debunne@google.com> | 2012-01-17 17:23:58 -0800 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2012-01-19 14:18:17 -0800 |
commit | 004b02d62605c172c3c9a332a22356cd4edf3598 (patch) | |
tree | b2d6186dbb6c40ac1d9a5934d3f4b182edeb7e5d /core/java/android/widget/TextView.java | |
parent | b3ca0fe66c1def11a04b18e6872318deb0340b9b (diff) | |
download | frameworks_base-004b02d62605c172c3c9a332a22356cd4edf3598.zip frameworks_base-004b02d62605c172c3c9a332a22356cd4edf3598.tar.gz frameworks_base-004b02d62605c172c3c9a332a22356cd4edf3598.tar.bz2 |
Touch moves cursor in text refactored
Code was moved back from the movement method to the touch event code in TextView.
Change-Id: I7dc0d957554ddce08e810d20e0385f98802ef1a4
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r-- | core/java/android/widget/TextView.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index e508e9a..b2112ed 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -8353,7 +8353,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } final boolean touchIsFinished = (action == MotionEvent.ACTION_UP) && - !shouldIgnoreActionUpEvent() && isFocused(); + !mIgnoreActionUpEvent && isFocused(); if ((mMovement != null || onCheckIsTextEditor()) && isEnabled() && mText instanceof Spannable && mLayout != null) { @@ -8377,6 +8377,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } if (touchIsFinished && (isTextEditable() || mTextIsSelectable)) { + // Move cursor + final int offset = getOffsetForPosition(event.getX(), event.getY()); + Selection.setSelection((Spannable) mText, offset); + // Show the IME, except when selecting in read-only text. final InputMethodManager imm = InputMethodManager.peekInstance(); viewClicked(imm); @@ -8529,17 +8533,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mIgnoreActionUpEvent = true; } - /** - * This method is only valid during a touch event. - * - * @return true when the ACTION_UP event should be ignored, false otherwise. - * - * @hide - */ - public boolean shouldIgnoreActionUpEvent() { - return mIgnoreActionUpEvent; - } - @Override public boolean onTrackballEvent(MotionEvent event) { if (mMovement != null && mText instanceof Spannable && @@ -10147,8 +10140,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener boolean willExtract = extractedTextModeWillBeStarted(); - // Do not start the action mode when extracted text will show up full screen, thus - // immediately hiding the newly created action bar, which would be visually distracting. + // Do not start the action mode when extracted text will show up full screen, which would + // immediately hide the newly created action bar and would be visually distracting. if (!willExtract) { ActionMode.Callback actionModeCallback = new SelectionActionModeCallback(); mSelectionActionMode = startActionMode(actionModeCallback); |