You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/04/15 02:11:56 UTC

git commit: CB-3324 Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed

Repository: cordova-plugin-inappbrowser
Updated Branches:
  refs/heads/dev 34c29dc2e -> 1c3223635


CB-3324 Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/1c322363
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/1c322363
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/1c322363

Branch: refs/heads/dev
Commit: 1c32236353d8fc118a8449464ba7cd8f93a5eee2
Parents: 34c29dc
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Apr 14 17:11:36 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Apr 14 17:11:36 2014 -0700

----------------------------------------------------------------------
 src/wp/InAppBrowser.cs | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/1c322363/src/wp/InAppBrowser.cs
----------------------------------------------------------------------
diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs
index 7239c8a..4026a95 100644
--- a/src/wp/InAppBrowser.cs
+++ b/src/wp/InAppBrowser.cs
@@ -331,6 +331,8 @@ namespace WPCordovaClassLib.Cordova.Commands
                             bar.IsVisible = !StartHidden;
                             AppBar = bar;
 
+                            page.BackKeyPress += page_BackKeyPress;
+
                         }
 
                     }
@@ -338,6 +340,23 @@ namespace WPCordovaClassLib.Cordova.Commands
             });
         }
 
+        void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
+        {
+#if WP8
+            if (browser.CanGoBack)
+            {
+                browser.GoBack();
+            }
+            else
+            {
+                close();
+            }
+            e.Cancel = true;
+#else
+                    browser.InvokeScript("execScript", "history.back();");
+#endif
+        }
+
         void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
         {
 
@@ -405,8 +424,10 @@ namespace WPCordovaClassLib.Cordova.Commands
                                 grid.Children.Remove(browser);
                             }
                             page.ApplicationBar = null;
+                            page.BackKeyPress -= page_BackKeyPress;
                         }
                     }
+                   
                     browser = null;
                     string message = "{\"type\":\"exit\"}";
                     PluginResult result = new PluginResult(PluginResult.Status.OK, message);