Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 812951838F for ; Fri, 6 Nov 2015 13:59:41 +0000 (UTC) Received: (qmail 73668 invoked by uid 500); 6 Nov 2015 13:59:41 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 73639 invoked by uid 500); 6 Nov 2015 13:59:41 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 73618 invoked by uid 99); 6 Nov 2015 13:59:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Nov 2015 13:59:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 32555DFDD0; Fri, 6 Nov 2015 13:59:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sgrebnov@apache.org To: commits@cordova.apache.org Date: Fri, 06 Nov 2015 13:59:41 -0000 Message-Id: <1449fc9de031440bb7b5a4e0a4e0fc0c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] cordova-windows git commit: CB-8481 Add support for backbutton on win10. This closes #120 Repository: cordova-windows Updated Branches: refs/heads/master 54085a69d -> 02a1ded1e CB-8481 Add support for backbutton on win10. This closes #120 Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/8a51ba9e Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/8a51ba9e Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/8a51ba9e Branch: refs/heads/master Commit: 8a51ba9eba9bb61b1ba1eaf28f9ea3c6e297f3f6 Parents: 54085a6 Author: Eion Robb Authored: Mon Sep 7 17:01:53 2015 +1200 Committer: sgrebnov Committed: Fri Nov 6 15:38:34 2015 +0300 ---------------------------------------------------------------------- cordova-js-src/platform.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/8a51ba9e/cordova-js-src/platform.js ---------------------------------------------------------------------- diff --git a/cordova-js-src/platform.js b/cordova-js-src/platform.js index fc668f0..62e011c 100644 --- a/cordova-js-src/platform.js +++ b/cordova-js-src/platform.js @@ -38,6 +38,24 @@ module.exports = { channel.onActivated = cordova.addDocumentEventHandler('activated'); } channel.onNativeReady.fire(); + + // Only load this code if we're running on Win10 in a non-emulated app frame, otherwise crash \o/ + if (parseInt(window.clientInformation.userAgent.match(/Windows NT ([0-9.]+)/)[1]) >= 10) { + var sysnavman = Windows.UI.Core.SystemNavigationManager.getForCurrentView(); + // Inject a listener for the backbutton on the document. + var backButtonChannel = cordova.addDocumentEventHandler('backbutton'); + backButtonChannel.onHasSubscribersChange = function() { + // If we just attached the first handler or detached the last handler, + // let native know we need to override the back button. + sysnavman.appViewBackButtonVisibility = (this.numHandlers == 1); + }; + + var backRequestedHandler = function backRequestedHandler() { + cordova.fireDocumentEvent('backbutton',null,true); + return true; + }; + sysnavman.addEventListener("backrequested", backRequestedHandler, false); + } var onWinJSReady = function () { var app = WinJS.Application; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org