离子/科尔多瓦menubutton事件不叫
问题描述:
我想要监控Android上的菜单按钮(4.4.2 - 三星S3),但 Ionic事件(以及底层的 Cordova事件)未启动:
I am trying to monitor the Menu Button on Android (4.4.2 - Samsung S3), but the Ionic event (nor the underlying Cordova event) is not firing:
$ionicPlatform.on("menubutton", function () {
// do our stuff here (never gets called)
});
有没有人能够做这项工作?
Has anyone been able to make this work? Running Ionic platform 1.0.0, and all other events are firing as expected.
答
文档缺少一行。
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