@@ -479,6 +479,38 @@ public boolean deleteSurroundingText(int leftLength, int rightLength) {
479479 return super .deleteSurroundingText (leftLength , rightLength );
480480 }
481481
482+ @ Override
483+ public boolean performEditorAction (int editorAction ) {
484+
485+ boolean handled = true ;
486+ switch (editorAction ) {
487+ case EditorInfo .IME_ACTION_NEXT :
488+ WebView .this .requestFocus (FOCUS_FORWARD );
489+ break ;
490+ case EditorInfo .IME_ACTION_PREVIOUS :
491+ WebView .this .requestFocus (FOCUS_BACKWARD );
492+ break ;
493+ case EditorInfo .IME_ACTION_DONE :
494+ WebView .this .hideSoftKeyboard ();
495+ break ;
496+ case EditorInfo .IME_ACTION_GO :
497+ case EditorInfo .IME_ACTION_SEARCH :
498+ WebView .this .hideSoftKeyboard ();
499+ String text = getEditable ().toString ();
500+ passToJavaScript (text , new KeyEvent (KeyEvent .ACTION_DOWN ,
501+ KeyEvent .KEYCODE_ENTER ));
502+ passToJavaScript (text , new KeyEvent (KeyEvent .ACTION_UP ,
503+ KeyEvent .KEYCODE_ENTER ));
504+ break ;
505+
506+ default :
507+ handled = super .performEditorAction (editorAction );
508+ break ;
509+ }
510+
511+ return handled ;
512+ }
513+
482514 public void initEditorInfo (WebViewCore .TextFieldInitData initData ) {
483515 int type = initData .mType ;
484516 int inputType = InputType .TYPE_CLASS_TEXT
@@ -578,7 +610,7 @@ private void setNewText(int start, int end, CharSequence text) {
578610 if (isCharacterAdd ) {
579611 sendCharacter (text .charAt (textLength - 1 ));
580612 } else if (isCharacterDelete ) {
581- sendDeleteKey ( );
613+ sendKey ( KeyEvent . KEYCODE_DEL );
582614 } else if ((textLength != originalLength ) ||
583615 !TextUtils .regionMatches (text , 0 , original , 0 ,
584616 textLength )) {
@@ -613,16 +645,18 @@ private void sendCharacter(char c) {
613645 }
614646
615647 /**
616- * Send the delete character as a key down and up event.
648+ * Send a key event for a specific key code, not a standard
649+ * unicode character.
650+ * @param keyCode The key code to send.
617651 */
618- private void sendDeleteKey ( ) {
652+ private void sendKey ( int keyCode ) {
619653 long eventTime = SystemClock .uptimeMillis ();
620654 sendKeyEvent (new KeyEvent (eventTime , eventTime ,
621- KeyEvent .ACTION_DOWN , KeyEvent . KEYCODE_DEL , 0 , 0 ,
655+ KeyEvent .ACTION_DOWN , keyCode , 0 , 0 ,
622656 KeyCharacterMap .VIRTUAL_KEYBOARD , 0 ,
623657 KeyEvent .FLAG_SOFT_KEYBOARD ));
624658 sendKeyEvent (new KeyEvent (SystemClock .uptimeMillis (), eventTime ,
625- KeyEvent .ACTION_UP , KeyEvent . KEYCODE_DEL , 0 , 0 ,
659+ KeyEvent .ACTION_UP , keyCode , 0 , 0 ,
626660 KeyCharacterMap .VIRTUAL_KEYBOARD , 0 ,
627661 KeyEvent .FLAG_SOFT_KEYBOARD ));
628662 }
0 commit comments