feat: allow user to multi-select regions.

This commit is contained in:
Xiaohan-Tian
2026-05-04 17:59:35 -07:00
parent bc7db712aa
commit 6d952b5b0b
10 changed files with 121 additions and 54 deletions
+4 -3
View File
@@ -16,6 +16,7 @@ import { showAlert } from '../util/dialogUtil';
*/
export const useGlobalKeyboardHandler = () => {
const { undo, redo, setStatus, isPlaying, startPlaying, stopTransport, toggleLoop, projectName, savedProjectName, setSavedProjectName, setProjectName, isRecording, startRecording, stopRecording, activeRegionId, selectedRegionIds, setActiveRegionId, setShowPianoRoll, showPianoRoll, openMidiPianoRoll, openSpectrogramViewer } = useProjectStore();
const lastSelectedRegionId = selectedRegionIds[selectedRegionIds.length - 1] ?? null;
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
@@ -166,7 +167,7 @@ export const useGlobalKeyboardHandler = () => {
setStatus('Recording stopped — notes committed');
return;
}
const candidateId = activeRegionId ?? (selectedRegionIds[0] ?? null);
const candidateId = activeRegionId ?? lastSelectedRegionId;
if (!candidateId) {
setStatus('Select a MIDI region before recording');
return;
@@ -201,7 +202,7 @@ export const useGlobalKeyboardHandler = () => {
setShowPianoRoll(false);
return;
}
const candidateId = activeRegionId ?? (selectedRegionIds[0] ?? null);
const candidateId = activeRegionId ?? lastSelectedRegionId;
if (!candidateId) {
void showAlert('Please select a region to open the editor.');
return;
@@ -264,7 +265,7 @@ export const useGlobalKeyboardHandler = () => {
startRecording,
stopRecording,
activeRegionId,
selectedRegionIds,
lastSelectedRegionId,
setActiveRegionId,
setShowPianoRoll,
showPianoRoll,