FIX: cho phép shift+click để chọn notes, drag để di chuyển các notes, ctrl+drag để copy nhanh các notes

This commit is contained in:
2026-08-07 21:48:14 +07:00
parent 688a7a57e2
commit 393df8fd7b
4 changed files with 55 additions and 5 deletions
+32 -2
View File
@@ -7762,8 +7762,9 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
}
}
// Ctrl+click: toggle selection (multi-select)
if (e.ctrlKey && !e.altKey && !e.shiftKey) {
// Shift+click: toggle selection (multi-select) user 09:30 (trưc đây là
// Ctrl+click Ctrl gi dành cho COPY-drag)
if (e.shiftKey && !e.altKey && !e.ctrlKey) {
if (clickedNoteIdx !== -1) {
const clickedNote = notes[clickedNoteIdx];
if (selectedNoteIds.includes(clickedNote.id)) {
@@ -7772,6 +7773,35 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
setSelectedNoteIds(prev => [...prev, clickedNote.id]);
}
return;
}
}
// Ctrl+click NOTE + drag COPY nhanh nhóm notes/note đến v trí mi
// (cùng pitch ban đu; drag đi v trí + pitch) user 09:30
if (e.ctrlKey && !e.altKey && !e.shiftKey) {
if (clickedNoteIdx !== -1) {
const clickedNote = notes[clickedNoteIdx];
const groupIds = (selectedNoteIds.includes(clickedNote.id) && selectedNoteIds.length > 1)
? selectedNoteIds : [clickedNote.id];
const src = notes.filter(n => groupIds.includes(n.id));
if (!src.length) return;
pushToUndo(notes);
notesBeforeDragRef.current = JSON.parse(JSON.stringify(notes));
const clones = src.map(n => ({ ...JSON.parse(JSON.stringify(n)), id: 'note_' + Date.now() + Math.random().toString(36).substr(2, 8) }));
setNotes(prev => [...prev, ...clones]);
const cloneIds = clones.map(c => c.id);
setSelectedNoteIds(cloneIds);
const cloneOffsets = clones.map(n => ({ id: n.id, originalStartBeat: n.start_beat, originalPitch: n.pitch }));
setDraggedNote({
mode: 'move',
idx: -1,
startOffsetBeat: beat - clickedNote.start_beat,
startOffsetPitch: pitch,
selectedNotesOffset: cloneOffsets,
clickedOriginalStartBeat: clickedNote.start_beat
});
showToast('Kéo để copy ' + clones.length + ' nốt.', 'info');
return;
} else {
// Ctrl+click on a dim (same-track) MIDI note select it and focus its MIDI item
var ctrlGhostHit = null;