You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Anatoly Shirokov (JIRA)" <ji...@apache.org> on 2017/01/13 10:33:26 UTC
[jira] [Created] (CB-12347) [cordova-android] menubutton and
searchbutton events are not fired
Anatoly Shirokov created CB-12347:
-------------------------------------
Summary: [cordova-android] menubutton and searchbutton events are not fired
Key: CB-12347
URL: https://issues.apache.org/jira/browse/CB-12347
Project: Apache Cordova
Issue Type: Bug
Components: Android, CordovaJS
Environment: android
Reporter: Anatoly Shirokov
Priority: Critical
I have ionic 2 project. I try to add event handler to the menubutton event:
document.addEventListener("menubutton", this.onMenuButtonPress, false);
But when I run my application on Android device and press menu button, my handler is never called.
I investigated https://github.com/apache/cordova-android/blob/master/cordova-js-src/platform.js and found, that menubutton and searchbutton are not overrided in opposite to volumeup, volumedown:
// Add hardware MENU and SEARCH button handlers
cordova.addDocumentEventHandler('menubutton');
cordova.addDocumentEventHandler('searchbutton');
function bindButtonChannel(buttonName) {
// generic button bind used for volumeup/volumedown buttons
var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
volumeButtonChannel.onHasSubscribersChange = function() {
exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]);
};
}
// Inject a listener for the volume buttons on the document.
bindButtonChannel('volumeup');
bindButtonChannel('volumedown');
To fix issue I have patched the platform.js:
function bindButtonChannelWithoutSuffix(buttonName) {
// generic button bind used for volumeup/volumedown buttons
var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName);
volumeButtonChannel.onHasSubscribersChange = function() {
exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]);
};
}
// Add hardware MENU and SEARCH button handlers
bindButtonChannelWithoutSuffix('menubutton');
bindButtonChannelWithoutSuffix('searchbutton');
function bindButtonChannel(buttonName) {
// generic button bind used for volumeup/volumedown buttons
var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
volumeButtonChannel.onHasSubscribersChange = function() {
exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]);
};
}
// Inject a listener for the volume buttons on the document.
bindButtonChannel('volumeup');
bindButtonChannel('volumedown');
Thanks in advance!
BR,
Anatoly Shirokov
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org