开发者

How do I Capture native (Menu) button presses in PhoneGap?

By calling BackButton.override(); and then hooking on to the backKeyDown event, I am able to get the back button press to register.

But there doesn't appear to be a MenuButton.override(); Also, hooking on the menuKeyDown doesn't register a button press.

Here's my (non-functional) code. What am I 开发者_StackOverflow社区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>


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

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

Hope this will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜