From fb81f3e77e4cc93dd26bf7fd324e9069964c5c3e Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 4 Mar 2013 14:26:28 -0800 Subject: [PATCH] CB-2596: Fixing the menubutton for text fields --- .../src/org/apache/cordova/CordovaWebView.java | 14 ++++++++++++++ framework/src/org/apache/cordova/DroidGap.java | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 0489a8aa..a1f423b2 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -47,6 +47,7 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; import android.webkit.WebBackForwardList; import android.webkit.WebHistoryItem; import android.webkit.WebChromeClient; @@ -736,6 +737,19 @@ public class CordovaWebView extends WebView { else return this.urls.size() > 1 || this.bound; } + else if(keyCode == KeyEvent.KEYCODE_MENU) + { + //How did we get here? Is there a childView? + View childView = this.getFocusedChild(); + if(childView != null) + { + //Make sure we close the keyboard if it's present + InputMethodManager imm = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(childView.getWindowToken(), 0); + cordova.getActivity().openOptionsMenu(); + } + return true; + } return super.onKeyDown(keyCode, event); } diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index 6b890f6e..d4296cbe 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -1062,7 +1062,8 @@ public class DroidGap extends Activity implements CordovaInterface { { //Get whatever has focus! View childView = appView.getFocusedChild(); - if ((appView.isCustomViewShowing() || childView != null ) && keyCode == KeyEvent.KEYCODE_BACK) { + if ((appView.isCustomViewShowing() || childView != null ) && + (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) { return appView.onKeyUp(keyCode, event); } else { return super.onKeyUp(keyCode, event); @@ -1082,7 +1083,7 @@ public class DroidGap extends Activity implements CordovaInterface { //Get whatever has focus! View childView = appView.getFocusedChild(); //Determine if the focus is on the current view or not - if (childView != null && keyCode == KeyEvent.KEYCODE_BACK) { + if (childView != null && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) { return appView.onKeyDown(keyCode, event); } else