diff --git a/plugins/Android/src/net/gree/unitywebview/CustomInputConnection.java b/plugins/Android/src/net/gree/unitywebview/CustomInputConnection.java new file mode 100644 index 00000000..410e7956 --- /dev/null +++ b/plugins/Android/src/net/gree/unitywebview/CustomInputConnection.java @@ -0,0 +1,33 @@ +package net.gree.unitywebview; + +import android.view.View; +import android.view.KeyEvent; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; +import android.view.inputmethod.BaseInputConnection; + +public class CustomInputConnection extends BaseInputConnection +{ + private CustomWebView mWebView; + + public CustomInputConnection(CustomWebView webView, boolean mutable) + { + super(webView, mutable); + mWebView = webView; + } + + @Override + public boolean sendKeyEvent(KeyEvent event) + { + switch (event.getAction()) + { + case KeyEvent.ACTION_DOWN: + mWebView.onKeyDown(event.getKeyCode(), event); + break; + case KeyEvent.ACTION_UP: + mWebView.onKeyUp(event.getKeyCode(), event); + break; + } + return super.sendKeyEvent(event); + } +} diff --git a/plugins/Android/src/net/gree/unitywebview/CustomWebView.java b/plugins/Android/src/net/gree/unitywebview/CustomWebView.java new file mode 100644 index 00000000..d7e6b682 --- /dev/null +++ b/plugins/Android/src/net/gree/unitywebview/CustomWebView.java @@ -0,0 +1,21 @@ +package net.gree.unitywebview; + +import android.content.Context; +import android.webkit.WebView; +import android.view.KeyEvent; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; + +public class CustomWebView extends WebView +{ + public CustomWebView(Context context) + { + super(context); + } + + @Override + public InputConnection onCreateInputConnection(EditorInfo outAttrs) + { + return new CustomInputConnection(this, false); + } +} diff --git a/plugins/Android/src/net/gree/unitywebview/WebViewPlugin.java b/plugins/Android/src/net/gree/unitywebview/WebViewPlugin.java index c9f9cd38..a0463aa1 100644 --- a/plugins/Android/src/net/gree/unitywebview/WebViewPlugin.java +++ b/plugins/Android/src/net/gree/unitywebview/WebViewPlugin.java @@ -72,7 +72,7 @@ public void Init(final String gameObject) final Activity a = UnityPlayer.currentActivity; a.runOnUiThread(new Runnable() {public void run() { - mWebView = new WebView(a); + mWebView = new CustomWebView(a); mWebView.setVisibility(View.GONE); mWebView.setFocusable(true); mWebView.setFocusableInTouchMode(true);