Windows phone back button support

0 favourites
  • 5 posts
From the Asset Store
Comprehensive localization solution for Construct 3 projects, no addons required!
  • Problem Description

    When exported as a Windows store project, the Hardware back button on Windows phones closes the construct2 application.

    Attach a Capx

    Simple capx

    https://www.dropbox.com/s/0n9xxb4rfz9zg40/BackButton.capx?dl=0

    Exported windows project

    https://www.dropbox.com/s/o3gwisp6vjvs0wh/BackButton.zip?dl=0

    Description of Capx

    It has two pages you can navigate between. The Hardware back button should navigate back through the page history but instead closes the app. This functionality is now a requirement for publishing to the Windows store, it's been introduced in the last few days.

    When you submit an app for certification you get the following error back after a few days

    [quote:10vkzcuf]App Policies: 10.4 Back Button

    Pressing the Back button must return the app to the previous page or return to any previous page within the back stack.

    /b]

    Steps to Reproduce Bug

      Export project for Windows store Open with visual studio Build and deploy to any mobile emulator (i.e. Mobile Emulator 10.0.10240.0 1080p 6 inch 2GB) Click the button "Page 1" to navigate to a new page Click on the Emulators Hardware Back Button

    Observed Result

    Application closes

    Expected Result

    Should navigating back to page 1

    Affected Browsers

      Windows Store Application

    Operating System and Service Pack

    Windows 10 Build 10586

    Construct 2 Version ID

    Release 227(64-bit)

  • Just a quick update with things I've tried.....

    This Javascript should work (thank you Google) but no luck yet, it still minimizes the app when the hardware back button is pressed. I've added a reference to Windows Mobile Extensions to the Visual studio project as well.

    <script type="text/javascript" charset="utf-8">

    var hardwareButtons = Windows.Phone.UI.Input.HardwareButtons;

    hardwareButtons.addEventListener("backpressed", function (e) {

    e.handled = true; // Notifies OS that you've handled the back button event.

    //Trigger an escape key press, I'm looking for this in Construct2 to trigger a back navigation

    var f = $.Event('keypress');

    f.which = 27; // Escape

    $('item').trigger(f);

    });

    </script>

    Then in Construct2 I have an array that I use as a stack to store all the pages I visit, when escape is pressed I pop the last page off the stack and navigate to it.

    But still no luck. Does anyone have any suggestions?

    This functionality of the back button means that no Construct2 Apps will be able to pass certification for the Windows store now which is not good.

  • Well, I've got a little further. If you hack out this code from c2runtime.js

    if (this.runtime.isWinJS && WinJS["Application"])

    {

    WinJS["Application"]["onbackclick"] = function (e)

    {

    return !!self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnBackButton, self);

    };

    }

    then you can add your own handler for onbackclick.

    However, I'd like to generate an escape key press with

    $(function() {

    var e = $.Event('keypress');

    e.which = 27; // Character 'ESC'

    $('item').trigger(e);

    });

    which I can look for in Construct2 but the key press is never getting through. If I do it in a standalone HTML file it works fine so I guess something else is conflicting with it........

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You need to add the Browser object to your game and handle the "on back button" trigger, otherwise it leaves the OS to do the default action. Closing as your .capx is working correctly. Please file a new issue if you still have trouble when using the Browser object's "on back button" trigger.

  • niknak68

    I think I have the same problem!

    The thing is that I have two projects, one with the back button working like a charm!, but with the other the app keeps minimizing.

    I don't know what to do!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)