diff options
| author | Leon Scroggins III <scroggo@google.com> | 2010-09-01 08:43:47 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-09-01 08:43:47 -0700 |
| commit | e1ab2228e27fc216d52426f13ae30ae244c64140 (patch) | |
| tree | 268fd5c767aa893740919605c3033afb721c0fcb /core | |
| parent | fff6e8e0c2d611c7126d43efb8cae3e814db93d6 (diff) | |
| parent | 3d540842f70f9719ff5abbac3bd492e7949d4aab (diff) | |
| download | frameworks_base-e1ab2228e27fc216d52426f13ae30ae244c64140.zip frameworks_base-e1ab2228e27fc216d52426f13ae30ae244c64140.tar.gz frameworks_base-e1ab2228e27fc216d52426f13ae30ae244c64140.tar.bz2 | |
Merge "Send delete key events when pressed at beginning of field."
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 48c065a..990f891 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -153,11 +153,13 @@ import java.util.ArrayList; return true; } Spannable text = (Spannable) getText(); - int oldLength = text.length(); + int oldStart = Selection.getSelectionStart(text); + int oldEnd = Selection.getSelectionEnd(text); // Normally the delete key's dom events are sent via onTextChanged. - // However, if the length is zero, the text did not change, so we - // go ahead and pass the key down immediately. - if (KeyEvent.KEYCODE_DEL == keyCode && 0 == oldLength) { + // However, if the cursor is at the beginning of the field, which + // includes the case where it has zero length, then the text is not + // changed, so send the events immediately. + if (KeyEvent.KEYCODE_DEL == keyCode && oldStart == 0 && oldEnd == 0) { sendDomEvent(event); return true; } @@ -197,9 +199,8 @@ import java.util.ArrayList; if (getLayout() == null) { measure(mWidthSpec, mHeightSpec); } - int oldStart = Selection.getSelectionStart(text); - int oldEnd = Selection.getSelectionEnd(text); + int oldLength = text.length(); boolean maxedOut = mMaxLength != -1 && oldLength == mMaxLength; // If we are at max length, and there is a selection rather than a // cursor, we need to store the text to compare later, since the key |
