diff options
| author | 2009-06-26 14:09:09 -0400 | |
|---|---|---|
| committer | 2009-06-29 10:16:24 -0400 | |
| commit | 0658e8fe4592a26de34170b62a19463fd2add47b (patch) | |
| tree | 27ede82ceacc135f37abdfacd6306c3e5ed8babc | |
| parent | 243ea06d2bf67e8b54da51977687b08f49aeb093 (diff) | |
If the cursor moves from a focused textfield to another, remove the WebTextView.
We already remove the blinking caret, implying that if the user
types with the cursor on another textfield, the keys will go there.
This way, the WebView will see the key, and rebuild the WebTextView,
so we no longer use the data from the first textfield. This fixes
a bug where moving from a focused textfield and pressing delete
with the cursor on another was deleting a character from the
first (initially focused) textfield. Also, in WebView::onKeyDown,
only check if the native cursor is a textfield before deciding
whether to send a CLICK, since plugins will be handled differently
(this is part of a different change), and now the cursor may match
the focus, but we still want the click (to make the focusController
active - i.e. make the cursor blink).
| -rw-r--r-- | core/java/android/webkit/WebView.java | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 5603ec90c228..1554d6ddec6f 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3285,17 +3285,15 @@ public class WebView extends AbsoluteLayout if (nativeCursorIsPlugin()) { nativeUpdatePluginReceivesEvents(); invalidate(); - } else if (nativeCursorWantsKeyEvents() && !nativeCursorMatchesFocus()) { + } else if (nativeCursorIsTextInput()) { // This message will put the node in focus, for the DOM's notion - // of focus + // of focus, and make the focuscontroller active mWebViewCore.sendMessage(EventHub.CLICK); - if (nativeCursorIsTextInput()) { - // This will bring up the WebTextView and put it in focus, for - // our view system's notion of focus - rebuildWebTextView(); - // Now we need to pass the event to it - return mWebTextView.onKeyDown(keyCode, event); - } + // This will bring up the WebTextView and put it in focus, for + // our view system's notion of focus + rebuildWebTextView(); + // Now we need to pass the event to it + return mWebTextView.onKeyDown(keyCode, event); } // TODO: should we pass all the keys to DOM or check the meta tag @@ -5180,12 +5178,23 @@ public class WebView extends AbsoluteLayout new WebViewCore.CursorData(frame, node, x, y)); } - // called by JNI - private void sendMoveMouseIfLatest(boolean setFocusControllerInactive) { - if (setFocusControllerInactive) { + /* + * Send a mouse move event to the webcore thread. + * + * @param removeFocus Pass true if the "mouse" cursor is now over a node + * which wants key events, but it is not the focus. This + * will make the visual appear as though nothing is in + * focus. Remove the WebTextView, if present, and stop + * drawing the blinking caret. + * called by JNI + */ + private void sendMoveMouseIfLatest(boolean removeFocus) { + if (removeFocus) { + clearTextEntry(); setFocusControllerInactive(); } - mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE_IF_LATEST, cursorData()); + mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE_IF_LATEST, + cursorData()); } // called by JNI |