2014-10-19 67 views
5

我在通过Cordova phonegap 4.0.0在Android上触发原生菜单按钮时遇到问题。我也实现了后退按钮,它工作正常。我无法弄清楚这里有什么问题。似乎没问题,根据科尔多瓦文档。在三星S4上运行测试时失败。phonegap cordova native android menubutton not firing

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'); 
} 

而且init函数加载之后调用,并且正如我所提到onBackKeyDown作品。任何提示赞赏。

+0

这似乎是一个错误,我也遇到它,你有没有发现一个解决方案? – 2015-07-04 18:56:25

+1

这是科尔多瓦的一个已知问题。 https://issues.apache.org/jira/browse/CB-8921 – Moussawi7 2015-08-14 09:39:58

回答

3

这被认为是固定的,但仍然需要一个无证的线。

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

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