diff --git a/src/frontend/containers/ContentView/Commands.tsx b/src/frontend/containers/ContentView/Commands.tsx index 0df063ee..0767bb43 100644 --- a/src/frontend/containers/ContentView/Commands.tsx +++ b/src/frontend/containers/ContentView/Commands.tsx @@ -82,12 +82,16 @@ export class CommandDispatcher { }); } - dragStart(event: BaseEvent) { + dragStart(event: MousePointerEvent) { event.stopPropagation(); event.preventDefault(); dispatchCustomEvent(event, { selector: Selector.FileDragStart, - payload: { file: this.file }, + payload: { + file: this.file, + selectAdditive: event.ctrlKey || event.metaKey, + selectRange: event.shiftKey, + }, }); } @@ -244,9 +248,10 @@ export function useCommandHandler( const handleDragStart = action((event: Event) => { event.stopPropagation(); - const file = (event as CommandHandlerEvent).detail.file; + const { file, selectAdditive, selectRange } = (event as CommandHandlerEvent) + .detail; if (!uiStore.fileSelection.has(file)) { - return; + select(file, selectAdditive, selectRange); } if (uiStore.fileSelection.size > 1) { RendererMessenger.startDragExport(Array.from(uiStore.fileSelection, (f) => f.absolutePath)); @@ -348,7 +353,8 @@ type ContentViewCommand = | Command | Command // Drag and Drop - | Command + | Command + | Command | Command; interface Command { @@ -379,6 +385,11 @@ interface SelectPayload extends Payload { selectRange: boolean; } +interface DragStartPayload extends Payload { + selectAdditive: boolean; + selectRange: boolean; +} + interface ContextMenuPayload extends Payload { x: number; y: number;