Skip to content

Commit 2b4d1cd

Browse files
authored
Fix: Play piano after adding a new note (sugarlabs#4125)
* Notes are playable * Update musickeyboard.js
1 parent 580a374 commit 2b4d1cd

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

js/widgets/musickeyboard.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,8 +2644,10 @@ function MusicKeyboard(activity) {
26442644
this.displayLayout[p].blockNumber
26452645
]);
26462646

2647-
this.displayLayout[p].objId = "blackRow" + myrow2Id.toString();
2648-
this.layout[p].objId = "blackRow" + myrow2Id.toString();
2647+
if (p < this.layout.length) {
2648+
this.displayLayout[p].objId = "blackRow" + myrow2Id.toString();
2649+
this.layout[p].objId = "blackRow" + myrow2Id.toString();
2650+
}
26492651

26502652
myrow2Id++;
26512653
newel2.innerHTML = "";
@@ -2749,9 +2751,10 @@ function MusicKeyboard(activity) {
27492751
")</small><br/>"
27502752
: "";
27512753
}
2752-
2753-
this.displayLayout[p].objId = "blackRow" + myrow2Id.toString();
2754-
this.layout[p].objId = "blackRow" + myrow2Id.toString();
2754+
if (p < this.layout.length) {
2755+
this.displayLayout[p].objId = "blackRow" + myrow2Id.toString();
2756+
this.layout[p].objId = "blackRow" + myrow2Id.toString();
2757+
}
27552758

27562759
myrow2Id++;
27572760
newel2.style.position = "relative";
@@ -2814,9 +2817,10 @@ function MusicKeyboard(activity) {
28142817
this.displayLayout[p].noteOctave;
28152818
}
28162819
}
2817-
2818-
this.displayLayout[p].objId = "blackRow" + myrow2Id.toString();
2819-
this.layout[p].objId = "blackRow" + myrow2Id.toString();
2820+
if (p < this.layout.length) {
2821+
this.displayLayout[p].objId = "blackRow" + myrow2Id.toString();
2822+
this.layout[p].objId = "blackRow" + myrow2Id.toString();
2823+
}
28202824

28212825
myrow2Id++;
28222826
newel2.style.position = "relative";
@@ -2863,9 +2867,10 @@ function MusicKeyboard(activity) {
28632867
this.displayLayout[p].noteOctave;
28642868
}
28652869
}
2866-
2867-
this.displayLayout[p].objId = "whiteRow" + myrowId.toString();
2868-
this.layout[p].objId = "whiteRow" + myrowId.toString();
2870+
if (p < this.layout.length) {
2871+
this.displayLayout[p].objId = "whiteRow" + myrowId.toString();
2872+
this.layout[p].objId = "whiteRow" + myrowId.toString();
2873+
}
28692874

28702875
myrowId++;
28712876
newel.style.position = "relative";

0 commit comments

Comments
 (0)