Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
keyForCoords method for the PianoView on the SSaurel's Channel
private Key keyForCoords(float x, float y) {
for (Key k : blacks) {
if (k.rect.contains(x,y)) {
return k;
}
}
for (Key k : whites) {
if (k.rect.contains(x,y)) {
return k;
}
}
return null;
}
private void releaseKey(final Key k) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
k.down = false;
handler.sendEmptyMessage(0);
}
}, 100);
}
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
invalidate();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.