Skip to content

Commit

Permalink
Added back button overriding (should kill CB-459) and proper firing o…
Browse files Browse the repository at this point in the history
…f events back into webview using cordova-js approach
  • Loading branch information
filmaj committed Apr 9, 2012
1 parent 7ded942 commit d4a0572
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions lib/wp7/platform.js
@@ -1,4 +1,5 @@

var cordova = require('cordova'),
exec = require('cordova/exec');

module.exports = {
id: "wp7",
Expand Down Expand Up @@ -207,7 +208,19 @@ if(!window.localStorage)
})();};



// INject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
onSubscribe:function() {
if (this.numHandlers === 1) {
exec(null, null, "CoreEvents", "overridebackbutton", [true]);
}
},
onUnsubscribe:function() {
if (this.numHandlers === 0) {
exec(null, null, "CoreEvents", "overridebackbutton", [false]);
}
}
});
},
objects: {
CordovaCommandResult: {
Expand Down
2 changes: 1 addition & 1 deletion lib/wp7/plugin/wp7/CordovaCommandResult.js
Expand Up @@ -6,7 +6,7 @@ var channel = require('cordova/channel');
module.exports = function(status,callbackId,args,cast) {

if(status === "backbutton") {
cordova.fireEvent(document,"backbutton");
cordova.fireDocumentEvent("backbutton");
return "true";
}
else if(status === "resume") {
Expand Down

0 comments on commit d4a0572

Please sign in to comment.