Skip to content

Commit e7aba40

Browse files
committed
Fix issue #380
1 parent 7ad279a commit e7aba40

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

src/data/examples/en/90_Hello_P5/07_song.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ function draw() {
105105
}
106106

107107
// When we click
108-
function mousePressed() {
109-
// Map mouse to the key index
110-
let key = floor(map(mouseX, 0, width, 0, notes.length));
111-
playNote(notes[key]);
108+
function mousePressed(event) {
109+
if(event.button == 0 && event.clientX < width && event.clientY < height) {
110+
// Map mouse to the key index
111+
var key = floor(map(mouseX, 0, width, 0, notes.length));
112+
playNote(notes[key]);
113+
}
112114
}
113115

114116
// Fade it out when we release

src/data/examples/es/90_Hello_P5/07_song.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ function draw() {
106106
}
107107

108108
// cuando hacemos click
109-
function mousePressed() {
110-
// mapear el ratón al índice de la tecla
111-
let key = floor(map(mouseX, 0, width, 0, notes.length));
112-
playNote(notes[key]);
109+
function mousePressed(event) {
110+
if(event.button == 0 && event.clientX < width && event.clientY < height) {
111+
// mapear el ratón al índice de la tecla
112+
var key = floor(map(mouseX, 0, width, 0, notes.length));
113+
playNote(notes[key]);
114+
}
113115
}
114116

115117
// Disminuye gradualmente cuando soltamos el botón del ratón

src/data/examples/zh-Hans/90_Hello_P5/07_song.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ function draw() {
105105
}
106106

107107
// When we click
108-
function mousePressed() {
109-
// Map mouse to the key index
110-
let key = floor(map(mouseX, 0, width, 0, notes.length));
111-
playNote(notes[key]);
108+
function mousePressed(event) {
109+
if(event.button == 0 && event.clientX < width && event.clientY < height) {
110+
// Map mouse to the key index
111+
var key = floor(map(mouseX, 0, width, 0, notes.length));
112+
playNote(notes[key]);
113+
}
112114
}
113115

114116
// Fade it out when we release

0 commit comments

Comments
 (0)