Skip to content

Commit

Permalink
fix #1093
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Jun 7, 2018
1 parent f0f94bf commit 35880e3
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ private void initKeyboardButton(View view)
if(focus != null && focus instanceof EditText)
{
EditText input = (EditText) focus;
int start = input.getSelectionStart();
int end = input.getSelectionEnd();
if ((input.getInputType() & InputType.TYPE_CLASS_NUMBER) != 0)
{
input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Expand All @@ -206,6 +208,8 @@ private void initKeyboardButton(View view)
input.setKeyListener(DigitsKeyListener.getInstance("0123456789.,- /"));
toggleKeyboardButton.setText("abc");
}
// for some reason, the cursor position gets lost first time the input type is set (#1093)
input.setSelection(start, end);

InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
Expand Down

0 comments on commit 35880e3

Please sign in to comment.