Make sure STKEdit focus is gone when not needed

This commit is contained in:
Benau 2019-05-27 14:25:08 +08:00
parent 72c61e412a
commit e24f95eefa

View File

@ -7,6 +7,7 @@ import android.text.InputType;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
@ -63,6 +64,16 @@ public class STKEditText extends EditText
@Override
public boolean onCheckIsTextEditor() { return true; }
// ------------------------------------------------------------------------
@Override
public boolean onKeyPreIme(int key_code, KeyEvent event)
{
// Always remove the focus on STKEdit when pressing back button in
// phone, which hideSoftInputFromWindow is called by java itself
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
beforeHideKeyboard();
return false;
}
// ------------------------------------------------------------------------
public void setComposingRegion(int start, int end)
{
// From doc of InputConnectionWrapper, it says: