phonegap cordova原生android menubutton没有开火

Dil*_*Dag 5 javascript android menu cordova

我无法通过Cordova phonegap 4.0.0在Android上触发本机菜单按钮.我也实现了后退按钮,它工作正常.我无法弄清楚这里有什么问题.根据cordova文档似乎没问题.在Samsung S4上运行测试时失败.

init : function () {
document.addEventListener("deviceready", this.onDeviceReady, false);
},

onDeviceReady : function() {
// Register the event listener
document.addEventListener('backbutton', this.onBackKeyDown, false);
document.addEventListener('menubutton', this.onMenuKeyDown, false);
},

onMenuKeyDown : function(event) {
alert('menu phone home');
}
Run Code Online (Sandbox Code Playgroud)

init : function () {
document.addEventListener("deviceready", this.onDeviceReady, false);
},

onDeviceReady : function() {
// Register the event listener
document.addEventListener('backbutton', this.onBackKeyDown, false);
document.addEventListener('menubutton', this.onMenuKeyDown, false);
},

onMenuKeyDown : function(event) {
alert('menu phone home');
}
Run Code Online (Sandbox Code Playgroud)

并且在load之后调用init函数,正如我在onBackKeyDown中提到的那样工作.任何提示赞赏.

Ali*_*ogy 3

这应该是固定的,但仍然需要一条未记录的线路。

document.addEventListener("deviceready", function() {
    ...
    navigator.app.overrideButton("menubutton", true);  // <-- Add this line
    document.addEventListener("menubutton", yourCallbackFunction, false);
    ...
}, false);
Run Code Online (Sandbox Code Playgroud)

https://issues.apache.org/jira/browse/CB-9949#comment-14989073