Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two tiles are cleared when pressing DEL button on one tile #36

Open
misaghE opened this issue Jun 1, 2019 · 1 comment
Open

Two tiles are cleared when pressing DEL button on one tile #36

misaghE opened this issue Jun 1, 2019 · 1 comment

Comments

@misaghE
Copy link

misaghE commented Jun 1, 2019

When I press DEL button to clear one tile (cursor is visible), the previous tile is also cleared. I debugged the code and found out that the problem maybe is in onKey() method:

 else if (currentTag > 0) {
                mDelPressed = true;
                if (editTextList.get(currentTag).length() == 0) {
                    //Takes it back one tile
                    editTextList.get(currentTag - 1).requestFocus();
                    //Clears the tile it just got to
                    editTextList.get(currentTag).setText("");
                } else {
                    //If it has some content clear it first
                    editTextList.get(currentTag).setText("");
                }
            }

I can't figure it out why calling setText("") when current tile has already length = 0. The previous tile has gained focus and so the currentFocus has been changed. Now calling setText("") on cached currentTag causes textChangeListener to get called and:

else if (charSequence.length() == 0) {
            int currentTag = getIndexOfCurrentFocus();
            mDelPressed = true;
            //For the last cell of the non password text fields. Clear the text without changing the focus.
            if (editTextList.get(currentTag).getText().length() > 0)
                editTextList.get(currentTag).setText("");
        }

Above lines clears the previous tile, because currentTag is now updated and previous tile is the currentFocus.

@misaghE
Copy link
Author

misaghE commented Jun 1, 2019

In fact, I can't understand why we should pass the focus to previous tile when DEL button is pressed!! We've cleared a tile to insert a new value on it.

editTextList.get(currentTag - 1).requestFocus();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant