Windows phone back button support

Bugs will be moved here once resolved.

Post » Thu Apr 28, 2016 8:35 pm

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

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.



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)
B
6
Posts: 5
Reputation: 262

Post » Fri Apr 29, 2016 12:03 pm

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.
B
6
Posts: 5
Reputation: 262

Post » Tue May 03, 2016 7:14 am

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........
B
6
Posts: 5
Reputation: 262

Post » Wed May 04, 2016 3:55 pm

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Wed Dec 07, 2016 2:46 am

@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!
B
92
S
30
G
11
Posts: 654
Reputation: 11,707


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest