Add comments to onKeyDown() method.

This commit is contained in:
Bryce Curtis 2010-11-11 14:08:55 -06:00
parent e8b85f6cf7
commit 49341356d7

View File

@ -787,33 +787,45 @@ public class DroidGap extends PhonegapActivity {
}
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
/**
* Called when a key is pressed.
*
* @param keyCode
* @param event
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// If back key
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (mKey.isBound())
{
//We fire an event here!
appView.loadUrl("javascript:document.keyEvent.backTrigger()");
// If back key is bound, then send event to JavaScript
if (mKey.isBound()) {
this.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();
// If not bound
else {
// Go to previous page in webview if it is possible to go back
if (this.appView.canGoBack()) {
this.appView.goBack();
}
else // if you can't go back, invoke behavior of super class
{
// If not, then invoke behavior of super class
else {
return super.onKeyDown(keyCode, event);
}
}
}
if (keyCode == KeyEvent.KEYCODE_MENU)
{
if (keyCode == KeyEvent.KEYCODE_MENU) {
// This is where we launch the menu
appView.loadUrl("javascript:keyEvent.menuTrigger()");
}
return false;
}