mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
Adding menu event and buttons
This commit is contained in:
parent
9a53dd7683
commit
de5b3e2c0f
@ -252,12 +252,12 @@ public class DroidGap extends Activity {
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU)
|
||||
{
|
||||
appView.loadUrl("javascript:fireMenuEvent()");
|
||||
appView.loadUrl("javascript:keyEvent.menuTrigger()");
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH)
|
||||
{
|
||||
appView.loadUrl("javascript:fireSearchEvent()");
|
||||
appView.loadUrl("javascript:keyEvent.searchTrigger()");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
22
js/keyevent.js
Normal file
22
js/keyevent.js
Normal file
@ -0,0 +1,22 @@
|
||||
function KeyEvent()
|
||||
{
|
||||
}
|
||||
|
||||
KeyEvent.prototype.menuTrigger = function()
|
||||
{
|
||||
var e = document.createEvent('Events');
|
||||
e.initEvent('menuKeyDown');
|
||||
document.dispatchEvent(e);
|
||||
}
|
||||
|
||||
KeyEvent.prototype.searchTrigger= function()
|
||||
{
|
||||
var e = document.createEvent('Events');
|
||||
e.initEvent('searchKeyDown');
|
||||
document.dispatchEvent(e);
|
||||
}
|
||||
|
||||
if (document.keyEvent == null || typeof document.keyEvent == 'undefined')
|
||||
{
|
||||
window.keyEvent = document.keyEvent = new KeyEvent();
|
||||
}
|
Loading…
Reference in New Issue
Block a user