mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
处理webview焦点变更后无法监听自定义按键的问题
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user