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:
+32
-2
@@ -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í mới
|
||||
// (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;
|
||||
|
||||
Reference in New Issue
Block a user