How to do a capture by clicking a button in PhoneGap?

By calling BackButton.override();and then connecting to the event backKeyDown, I can click the "Back" button to register.

But does not exist MenuButton.override();. In addition, when connected to a menuKeyDownbutton is not recorded.

Here is my (non-functional) code. What am I missing?

<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>      

  <script type="text/javascript" charset="utf-8">
        document.addEventListener("deviceready", function() {

            alert('initialized');
    }, false);
    document.addEventListener("menuKeyDown", function() {

            alert('menu_pressed'); // Never happens
    }, false);
  </script>
+3
source share
1 answer

The latest version of phongap.js does not support the overriding menu key for this edit; you will copy the following code:

KeyEvent.prototype.menuTrigger = function()
{
  var e = document.createEvent('Events');
  e.initEvent('menuKeyDown');
  document.dispatchEvent(e);
}

Hope this helps you.

+2
source

Source: https://habr.com/ru/post/1778889/


All Articles