Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 9ab6581

Browse files
keianhzobluemarvin
authored andcommitted
Fixes clicks outside key bounds (#2637)
1 parent 8a2f86a commit 9ab6581

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomKeyboardView.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,18 @@ private void onBufferDraw() {
880880
mDirtyRect.setEmpty();
881881
}
882882

883+
/**
884+
* We use our own Key.isInside implementation {@link Keyboard#isInside} as that one assumes that the
885+
* motion event is inside the key if it is an edge key.
886+
*/
887+
public boolean isInside(Key key, int x, int y) {
888+
if ((x >= key.x) && (x < key.x + key.width) && (y >= key.y) && (y < key.y + key.height)) {
889+
return true;
890+
} else {
891+
return false;
892+
}
893+
}
894+
883895
private int getKeyIndices(int x, int y, int[] allKeys) {
884896
final Key[] keys = mKeys;
885897
int primaryIndex = NOT_A_KEY;
@@ -891,7 +903,7 @@ private int getKeyIndices(int x, int y, int[] allKeys) {
891903
for (int i = 0; i < keyCount; i++) {
892904
final Key key = keys[nearestKeyIndices[i]];
893905
int dist = 0;
894-
boolean isInside = key.isInside(x,y);
906+
boolean isInside = isInside(key, x,y);
895907
if (isInside) {
896908
primaryIndex = nearestKeyIndices[i];
897909
}

0 commit comments

Comments
 (0)