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

Fixes #2565 Fixes clicks outside key bounds #2637

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,18 @@ private void onBufferDraw() {
mDirtyRect.setEmpty();
}

/**
* We use our own Key.isInside implementation {@link Keyboard#isInside} as that one assumes that the
* motion event is inside the key if it is an edge key.
*/
public boolean isInside(Key key, int x, int y) {
if ((x >= key.x) && (x < key.x + key.width) && (y >= key.y) && (y < key.y + key.height)) {
return true;
} else {
return false;
}
}

private int getKeyIndices(int x, int y, int[] allKeys) {
final Key[] keys = mKeys;
int primaryIndex = NOT_A_KEY;
Expand All @@ -891,7 +903,7 @@ private int getKeyIndices(int x, int y, int[] allKeys) {
for (int i = 0; i < keyCount; i++) {
final Key key = keys[nearestKeyIndices[i]];
int dist = 0;
boolean isInside = key.isInside(x,y);
boolean isInside = isInside(key, x,y);
if (isInside) {
primaryIndex = nearestKeyIndices[i];
}
Expand Down