mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-28 22:10:25 +08:00
Add comments to onKeyDown() method.
This commit is contained in:
parent
e8b85f6cf7
commit
49341356d7
@ -787,34 +787,46 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
|
||||||
{
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
||||||
if (mKey.isBound())
|
|
||||||
{
|
|
||||||
//We fire an event here!
|
|
||||||
appView.loadUrl("javascript:document.keyEvent.backTrigger()");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// only go back if the webview tells you that it is possible to go back
|
|
||||||
if(appView.canGoBack())
|
|
||||||
{
|
|
||||||
appView.goBack();
|
|
||||||
}
|
|
||||||
else // if you can't go back, invoke behavior of super class
|
|
||||||
{
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_MENU)
|
/**
|
||||||
{
|
* Called when a key is pressed.
|
||||||
// This is where we launch the menu
|
*
|
||||||
appView.loadUrl("javascript:keyEvent.menuTrigger()");
|
* @param keyCode
|
||||||
}
|
* @param event
|
||||||
return false;
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
|
||||||
|
// If back key
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
|
|
||||||
|
// If back key is bound, then send event to JavaScript
|
||||||
|
if (mKey.isBound()) {
|
||||||
|
this.appView.loadUrl("javascript:document.keyEvent.backTrigger()");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not bound
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Go to previous page in webview if it is possible to go back
|
||||||
|
if (this.appView.canGoBack()) {
|
||||||
|
this.appView.goBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not, then invoke behavior of super class
|
||||||
|
else {
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_MENU) {
|
||||||
|
// This is where we launch the menu
|
||||||
|
appView.loadUrl("javascript:keyEvent.menuTrigger()");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user