summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/WebTextView.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2009-07-02 10:37:10 -0400
committerLeon Scroggins <scroggo@google.com>2009-07-06 11:15:07 -0400
commit4890feb048e4f0510c577babe3bfd08521a3996b (patch)
tree0f4373ae969e7ad68269d2abfc2b2093266fb94b /core/java/android/webkit/WebTextView.java
parentf8e3ba5bfad14f3037d72eb6243258c13169cbd8 (diff)
In WebTextView, check the focus before sending a key.
This fixes a bug where the DOM has moved the focus, but the WebTextView is still sending keys to the old focus. Requires a change in external/webkit.
Diffstat (limited to 'core/java/android/webkit/WebTextView.java')
-rw-r--r--core/java/android/webkit/WebTextView.java36
1 files changed, 22 insertions, 14 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index 25a20f2e2221..23c7f7d6651d 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -93,6 +93,28 @@ import java.util.ArrayList;
// Treat ACTION_DOWN and ACTION MULTIPLE the same
boolean down = event.getAction() != KeyEvent.ACTION_UP;
int keyCode = event.getKeyCode();
+
+ boolean isArrowKey = false;
+ switch(keyCode) {
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ case KeyEvent.KEYCODE_DPAD_UP:
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ if (!mWebView.nativeCursorMatchesFocus()) {
+ return down ? mWebView.onKeyDown(keyCode, event) : mWebView
+ .onKeyUp(keyCode, event);
+
+ }
+ isArrowKey = true;
+ break;
+ }
+
+ if (!isArrowKey && mWebView.nativeFocusNodePointer() != mNodePointer) {
+ mWebView.nativeClearCursor();
+ remove();
+ return mWebView.dispatchKeyEvent(event);
+ }
+
Spannable text = (Spannable) getText();
int oldLength = text.length();
// Normally the delete key's dom events are sent via onTextChanged.
@@ -133,20 +155,6 @@ import java.util.ArrayList;
// Pass to super to handle longpress.
return super.dispatchKeyEvent(event);
}
- boolean isArrowKey = false;
- switch(keyCode) {
- case KeyEvent.KEYCODE_DPAD_LEFT:
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- case KeyEvent.KEYCODE_DPAD_UP:
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (!mWebView.nativeCursorMatchesFocus()) {
- return down ? mWebView.onKeyDown(keyCode, event) : mWebView
- .onKeyUp(keyCode, event);
-
- }
- isArrowKey = true;
- break;
- }
// Ensure there is a layout so arrow keys are handled properly.
if (getLayout() == null) {