Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Android hardware menu button not working with Cordova 5.1.1 and Ionic 1.1.0

$
0
0

@jagrawal wrote:

Android hardware menu button event 'menubutton' does not seem to be firing on document.
I have tried adding event listeners in a .run() block as most people recommend and also in a .controller() but to no avail.

.controller(function($document, $ionicSideMenuDelegate){

  var menuButtonFn = function(){
    console.log('in controller');
    $ionicSideMenuDelegate.toggleLeft();
  };

  $document.on('menubutton', menuButtonFn);
  document.addEventListener("menubutton", menuButtonFn, false);
})

.run(function($rootScope, $ionicPlatform, $cordovaStatusbar) {

  $ionicPlatform.ready(function() {

    function menuButtonFn(){
      console.log('here now');
      $rootScope.$broadcast('menubutton');
    }

    if (window.cordova) {
      document.addEventListener("menubutton", menuButtonFn, false);
    }
})

I have been testing on a Samsung Galaxy S4 using ionic run android`. I don't see any errors or logs in the chrome://inspect view and any other code is definitely not being triggered.
Not sure if I am missing something obvious. Has anyone else had the same problem?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles