forked from github/cordova-android
处理webview焦点变更后无法监听自定义按键的问题
This commit is contained in:
parent
8a09faeacd
commit
60c71059bf
@ -79,6 +79,13 @@ public class SystemWebView extends WebView implements CordovaWebViewEngine.Engin
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if(event.getKeyCode()>=520 && event.getKeyCode() <=523){
|
||||
if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
loadUrl("javascript:cordova.fireWindowEvent('native.onKeyUp',{keycode:"+event.getKeyCode()+"})");
|
||||
} else if(event.getAction() == KeyEvent.ACTION_DOWN){
|
||||
loadUrl("javascript:cordova.fireWindowEvent('native.onKeyDown',{keycode:"+event.getKeyCode()+"})");
|
||||
}
|
||||
}
|
||||
Boolean ret = parentEngine.client.onDispatchKeyEvent(event);
|
||||
if (ret != null) {
|
||||
return ret.booleanValue();
|
||||
|
Loading…
Reference in New Issue
Block a user