Skip to content

Commit

Permalink
Merge pull request #453 from ryohey/fix-select-all-notes
Browse files Browse the repository at this point in the history
fix ctrl+a to select all notes
  • Loading branch information
ryohey authored Feb 1, 2025
2 parents adfe296 + d9ae967 commit 0cedc1c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/src/actions/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ export const useSelectAllNotes = () => {
const {
pianoRollStore,
pianoRollStore: { selectedTrack },
controlStore,
} = useStores()
return () => {
if (selectedTrack) {
pianoRollStore.selectedNoteIds = selectedTrack.events
.filter(isNoteEvent)
.map((note) => note.id)
controlStore.selectedEventIds = []
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { observer } from "mobx-react-lite"
import { FC } from "react"
import { usePasteSelection } from "../../actions"
import { usePasteSelection, useSelectAllNotes } from "../../actions"
import { usePasteControlSelection } from "../../actions/control"
import {
isControlEventsClipboardData,
Expand All @@ -23,6 +23,7 @@ export const PianoRollKeyboardShortcut: FC = observer(() => {
useControlPaneKeyboardShortcutActions()
const pasteSelection = usePasteSelection()
const pasteControlSelection = usePasteControlSelection()
const selectAllNotes = useSelectAllNotes()

// Handle pasting here to allow pasting even when the element does not have focus, such as after clicking the ruler
const onPaste = (e: ClipboardEvent) => {
Expand Down Expand Up @@ -82,6 +83,11 @@ export const PianoRollKeyboardShortcut: FC = observer(() => {
code: "Digit2",
run: () => (pianoRollStore.mouseMode = "selection"),
},
{
code: "KeyA",
metaKey: true,
run: selectAllNotes,
},
]}
onPaste={onPaste}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
useDuplicateSelection,
usePasteSelection,
useQuantizeSelectedNotes,
useSelectAllNotes,
useSelectNextNote,
useSelectPreviousNote,
useTransposeSelection,
Expand All @@ -18,7 +17,6 @@ export const usePianoNotesKeyboardShortcutActions = () => {
const deleteSelection = useDeleteSelection()
const pasteSelection = usePasteSelection()
const duplicateSelection = useDuplicateSelection()
const selectAllNotes = useSelectAllNotes()
const quantizeSelectedNotes = useQuantizeSelectedNotes()
const transposeSelection = useTransposeSelection()
const { pianoRollStore } = useStores()
Expand Down Expand Up @@ -47,11 +45,6 @@ export const usePianoNotesKeyboardShortcutActions = () => {
metaKey: true,
run: duplicateSelection,
},
{
code: "KeyA",
metaKey: true,
run: selectAllNotes,
},
{
code: "KeyQ",
run: quantizeSelectedNotes,
Expand Down

0 comments on commit 0cedc1c

Please sign in to comment.