Alt click scene select dropdown to jump to that scene
import React, { FC, useState, useEffect } from "react";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
import { assetFilename } from "../../lib/helpers/gbstudio";
import {
backgroundSelectors,
@@ -15,6 +15,7 @@ import {
import { Scene } from "../../store/features/entities/entitiesTypes";
import { RootState } from "../../store/configureStore";
import styled from "styled-components";
+import editorActions from "../../store/features/editor/editorActions";
interface SceneSelectProps extends SelectCommonProps {
name: string;
@@ -70,6 +71,7 @@ export const SceneSelect: FC<SceneSelectProps> = ({
const [options, setOptions] = useState<SceneOption[]>([]);
const [currentScene, setCurrentScene] = useState<Scene>();
const [currentValue, setCurrentValue] = useState<Option>();
+ const dispatch = useDispatch();
useEffect(() => {
setOptions(scenes.map(sceneToSceneOption).sort(sortByLabel));
@@ -91,7 +93,17 @@ export const SceneSelect: FC<SceneSelectProps> = ({
onChange?.(newValue.value);
};
+ const onJumpToScene = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
+ if (e.altKey) {
+ if (value) {
+ dispatch(editorActions.selectScene({ sceneId: value }));
+ dispatch(editorActions.setFocusSceneId(value));
+ }
+ }
+ };
+
return (
+ <div onClick={onJumpToScene}>
<Select
value={currentValue}
options={options}
@@ -142,5 +154,6 @@ export const SceneSelect: FC<SceneSelectProps> = ({
}}
{...selectProps}
/>
+ </div>
);
};
