Only give WebTextView keys if it has focus.

Bug:3460690
Change-Id: Iab82dc2c6e07a83062338ede8428e9d81ef0b949
This commit is contained in:
Leon Scroggins
2011-02-17 13:51:50 -05:00
parent 90e711670a
commit defba0cabe

View File

@@ -5275,7 +5275,6 @@ public class WebView extends AbsoluteLayout
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
boolean dispatch = true;
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
mKeysPressed.add(Integer.valueOf(event.getKeyCode()));
@@ -5288,7 +5287,7 @@ public class WebView extends AbsoluteLayout
if (location == -1) {
// We did not receive the key down for this key, so do not
// handle the key up.
dispatch = false;
return false;
} else {
// We did receive the key down. Handle the key up, and
// remove it from our pressed keys.
@@ -5300,17 +5299,12 @@ public class WebView extends AbsoluteLayout
// action is added to KeyEvent.
break;
}
if (dispatch) {
if (inEditingMode()) {
// Ensure that the WebTextView gets the event, even if it does
// not currently have a bounds.
return mWebTextView.dispatchKeyEvent(event);
} else {
return super.dispatchKeyEvent(event);
}
if (inEditingMode() && mWebTextView.isFocused()) {
// Ensure that the WebTextView gets the event, even if it does
// not currently have a bounds.
return mWebTextView.dispatchKeyEvent(event);
} else {
// We didn't dispatch, so let something else handle the key
return false;
return super.dispatchKeyEvent(event);
}
}