06-30-2016, 02:31 AM
(This post was last modified: 06-30-2016, 02:45 AM by NothingHere.
Edit Reason: Remove console.log line as it's unnecessary
)
A really basic yet missing feature is the ability to hold CTRL (or Command for Macs) to select multiple notes with ease.
Below is a simple yet working implementation:
Below is a simple yet working implementation:
Code:
// Tracks control key state
var ctrlDown = false;
// Override existing onNoteClick function
function onNoteClick(event) {
var element = document.elementFromPoint(event.clientX, event.clientY);
if (element != undefined && element.noteData != undefined && !instrumentLock[element.noteData.instrument]) {
var note = element.noteData;
if (note.selected == false) {
// If control is down, don't clear the selection
if(!ctrlDown)
clearSelection();
select(note);
}
dragSelection();
playNote(note.instrument, note.type, note.length);
window.top.confirmExit = true;
return clickedNote = true;
} else {
// Don't clear the selection in-case the user accidentally misses the note
if(!ctrlDown)
clearSelection();
return clickedNote = false;
}
}
// Event listeners for the control key
window.addEventListener("keydown", function(event) {
if (event.keyCode == 17) {
ctrlDown = true;
}
}, false);
window.addEventListener("keyup", function(event) {
if (event.keyCode == 17) {
ctrlDown = false;
}
}, false);