Skip to content

Commit d8f50fe

Browse files
committed
Toggle multi selection of scenes action changed to ctrl/cmd + click
1 parent ae071b4 commit d8f50fe

File tree

3 files changed

+16
-39
lines changed

3 files changed

+16
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- Ladder collision tile now only visible on Platform scenes by default, edit `engine.json` to add per scene collision tile types
3939
- New instances of prefabs use prefab's name by default
4040
- Update "Wait" event to support using variable values for wait time [@pau-tomas](https://github.com/pau-tomas))
41+
- Toggle multi selection of scenes action changed to ctrl/cmd + click to be more consistent with OS level defaults + new sprite editor frame selection
4142
- Updated Polish localisation. [@ReptiIe](https://github.com/ReptiIe)
4243
- Updated Japanese localisation. [@tomo666](https://github.com/tomo666)
4344

src/components/world/SceneView.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ interface SceneViewProps {
5858
id: string;
5959
index: number;
6060
editable?: boolean;
61-
addToSelection?: boolean;
6261
}
6362

6463
const SceneName = styled.div`
@@ -199,16 +198,8 @@ const SceneOverlay = styled.div<SceneOverlayProps>`
199198
: ""}
200199
`;
201200

202-
const SelectionWrapper = styled.div`
203-
position: absolute;
204-
top: 0;
205-
left: 0;
206-
width: 100%;
207-
height: 100%;
208-
`;
209-
210201
const SceneView = memo(
211-
({ id, index, editable, addToSelection }: SceneViewProps) => {
202+
({ id, index, editable }: SceneViewProps) => {
212203
const dispatch = useAppDispatch();
213204
const scene = useAppSelector((state) =>
214205
sceneSelectors.selectById(state, id)
@@ -620,9 +611,16 @@ const SceneView = memo(
620611
[renderContextMenu, tool]
621612
);
622613

623-
const onToggleSelection = useCallback(() => {
624-
dispatch(editorActions.toggleSceneSelectedId(id));
625-
}, [dispatch, id]);
614+
const onToggleSelection = useCallback(
615+
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
616+
if (e.ctrlKey || e.metaKey) {
617+
e.preventDefault();
618+
e.stopPropagation();
619+
dispatch(editorActions.toggleSceneSelectedId(id));
620+
}
621+
},
622+
[dispatch, id]
623+
);
626624

627625
if (!scene || !visible) {
628626
return <></>;
@@ -638,6 +636,7 @@ const SceneView = memo(
638636
top: scene.y,
639637
}}
640638
onContextMenu={onContextMenu}
639+
onMouseDownCapture={onToggleSelection}
641640
>
642641
<SceneMetadata
643642
onMouseDown={onStartDrag}
@@ -818,8 +817,6 @@ const SceneView = memo(
818817
{contextMenu.menu}
819818
</ContextMenu>
820819
)}
821-
822-
{addToSelection && <SelectionWrapper onMouseDown={onToggleSelection} />}
823820
</Wrapper>
824821
);
825822
}

src/components/world/WorldView.tsx

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ const WorldContent = styled.div`
5353
left: 0;
5454
`;
5555

56-
const SelectionWrapper = styled.div`
57-
position: absolute;
58-
top: 0;
59-
left: 0;
60-
width: 100%;
61-
height: 100%;
62-
`;
63-
6456
const NewSceneCursor = styled.div`
6557
position: absolute;
6658
cursor: pointer;
@@ -110,7 +102,6 @@ const WorldView = () => {
110102
scrollY: 0,
111103
});
112104
const isMouseOver = useRef(false);
113-
const [addToSelection, setAddToSelection] = useState(false);
114105
const [selectionStart, setSelectionStart] = useState<Point>();
115106
const [selectionEnd, setSelectionEnd] = useState<Point>();
116107
const selection = useRef<SelectionRect>();
@@ -221,7 +212,6 @@ const WorldView = () => {
221212
if (e.shiftKey && tool === "select") {
222213
setSelectionStart(undefined);
223214
setSelectionEnd(undefined);
224-
setAddToSelection(true);
225215
}
226216
if (!(e.target instanceof HTMLElement)) return;
227217
if (e.target.nodeName !== "BODY") {
@@ -249,9 +239,6 @@ const WorldView = () => {
249239
if (dragMode && (e.code === "Space" || e.key === "Alt")) {
250240
setDragMode(false);
251241
}
252-
if (!e.shiftKey) {
253-
setAddToSelection(false);
254-
}
255242
},
256243
[dragMode]
257244
);
@@ -600,8 +587,8 @@ const WorldView = () => {
600587
);
601588

602589
const onStartMultiSelection = useCallback(
603-
(e: React.MouseEvent<HTMLDivElement>) => {
604-
if (scrollRef.current) {
590+
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
591+
if (e.shiftKey && scrollRef.current) {
605592
e.preventDefault();
606593
e.stopPropagation();
607594

@@ -632,7 +619,6 @@ const WorldView = () => {
632619

633620
const onWindowBlur = useCallback(() => {
634621
setDragMode(false);
635-
setAddToSelection(false);
636622
}, []);
637623

638624
//#endregion Window Blur
@@ -679,6 +665,7 @@ const WorldView = () => {
679665
onMouseLeave={onMouseLeave}
680666
onMouseMove={onMouseMove}
681667
onMouseDown={startWorldDragIfAltOrMiddleClick}
668+
onMouseDownCapture={onStartMultiSelection}
682669
onScroll={onScroll}
683670
style={
684671
dragMode
@@ -697,20 +684,12 @@ const WorldView = () => {
697684
onMouseDown={startWorldDrag}
698685
/>
699686

700-
{addToSelection && (
701-
<SelectionWrapper
702-
style={{ width: scrollWidth, height: scrollHeight }}
703-
onMouseDown={onStartMultiSelection}
704-
></SelectionWrapper>
705-
)}
706-
707687
{scenes.map((sceneId, index) => (
708688
<SceneView
709689
key={sceneId}
710690
id={sceneId}
711691
index={index}
712692
editable={!dragMode}
713-
addToSelection={addToSelection}
714693
/>
715694
))}
716695

0 commit comments

Comments
 (0)