updated
This commit is contained in:
@@ -1,31 +1,35 @@
|
||||
// Function to detect if Shift, Ctrl, Alt, or combinations are pressed
|
||||
// and return the corresponding key combination string
|
||||
export const detectModifierKeys = (event: KeyboardEvent): string => {
|
||||
const modifiers = [
|
||||
event.ctrlKey ? "Ctrl" : "",
|
||||
event.altKey ? "Alt" : "",
|
||||
event.shiftKey ? "Shift" : "",
|
||||
event.metaKey ? "Meta" : "" // Add support for Command/Win key
|
||||
].filter(Boolean);
|
||||
const modifiers = [
|
||||
event.ctrlKey ? "Ctrl" : "",
|
||||
event.altKey ? "Alt" : "",
|
||||
event.shiftKey ? "Shift" : "",
|
||||
event.metaKey ? "Meta" : "", // Add support for Command/Win key
|
||||
].filter(Boolean);
|
||||
|
||||
// Ignore modifier keys when they're pressed alone
|
||||
const isModifierKey = [
|
||||
"Control", "Shift", "Alt", "Meta",
|
||||
"Ctrl", "AltGraph", "OS" // Additional modifier key aliases
|
||||
].includes(event.key);
|
||||
// Ignore modifier keys when they're pressed alone
|
||||
const isModifierKey = [
|
||||
"Control",
|
||||
"Shift",
|
||||
"Alt",
|
||||
"Meta",
|
||||
"Ctrl",
|
||||
"AltGraph",
|
||||
"OS", // Additional modifier key aliases
|
||||
].includes(event.key);
|
||||
|
||||
const mainKey = isModifierKey ? "" : event.key.toUpperCase();
|
||||
const mainKey = isModifierKey ? "" : event.key.toUpperCase();
|
||||
|
||||
// Handle special cases for keys with different representations
|
||||
const normalizedKey = mainKey === " " ? "Space" : mainKey;
|
||||
|
||||
// Handle special cases for keys with different representations
|
||||
const normalizedKey = mainKey === " " ? "Space" : mainKey;
|
||||
|
||||
// Build the combination string
|
||||
if (modifiers.length > 0 && normalizedKey) {
|
||||
return `${modifiers.join("+")}+${normalizedKey}`;
|
||||
} else if (modifiers.length > 0) {
|
||||
return modifiers.join("+");
|
||||
} else {
|
||||
return normalizedKey;
|
||||
}
|
||||
// Build the combination string
|
||||
if (modifiers.length > 0 && normalizedKey) {
|
||||
return `${modifiers.join("+")}+${normalizedKey}`;
|
||||
} else if (modifiers.length > 0) {
|
||||
return modifiers.join("+");
|
||||
} else {
|
||||
return normalizedKey;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import React, { useEffect } from "react";
|
||||
import useModuleStore, { useThreeDStore } from "../../store/useModuleStore";
|
||||
import useModuleStore, { useSubModuleStore, useThreeDStore } from "../../store/useModuleStore";
|
||||
import { usePlayerStore, useToggleStore } from "../../store/useUIToggleStore";
|
||||
import {
|
||||
import useVersionHistoryVisibleStore, {
|
||||
useActiveSubTool,
|
||||
useActiveTool,
|
||||
useAddAction,
|
||||
useRenameModeStore,
|
||||
useSaveVersion,
|
||||
useSelectedComment,
|
||||
useSelectedFloorItem,
|
||||
useSelectedWallItem,
|
||||
useShortcutStore,
|
||||
@@ -21,10 +22,12 @@ import { detectModifierKeys } from "./detectModifierKeys";
|
||||
import { useSelectedZoneStore } from "../../store/visualization/useZoneStore";
|
||||
import { useLogger } from "../../components/ui/log/LoggerContext";
|
||||
import { useComparisonProduct } from "../../store/simulation/useSimulationStore";
|
||||
import { useVersionHistoryStore } from "../../store/builder/useVersionHistoryStore";
|
||||
|
||||
const KeyPressListener: React.FC = () => {
|
||||
const { clearComparisonProduct } = useComparisonProduct();
|
||||
const { comparisonProduct, clearComparisonProduct } = useComparisonProduct();
|
||||
const { activeModule, setActiveModule } = useModuleStore();
|
||||
const { setSubModule } = useSubModuleStore();
|
||||
const { setActiveSubTool } = useActiveSubTool();
|
||||
const { toggleUILeft, toggleUIRight, setToggleUI } = useToggleStore();
|
||||
const { setToggleThreeD } = useThreeDStore();
|
||||
@@ -40,10 +43,13 @@ const KeyPressListener: React.FC = () => {
|
||||
const { setIsVersionSaved } = useSaveVersion();
|
||||
const { isLogListVisible, setIsLogListVisible } = useLogger();
|
||||
const { hidePlayer, setHidePlayer } = usePlayerStore();
|
||||
const { viewSceneLabels, setViewSceneLabels } = useViewSceneStore();
|
||||
const { setViewSceneLabels } = useViewSceneStore();
|
||||
const { isRenameMode, setIsRenameMode } = useRenameModeStore();
|
||||
const { selectedFloorItem } = useSelectedFloorItem();
|
||||
|
||||
const { setCreateNewVersion } = useVersionHistoryStore();
|
||||
const { setVersionHistoryVisible } = useVersionHistoryVisibleStore();
|
||||
const { setSelectedComment } = useSelectedComment();
|
||||
|
||||
const isTextInput = (element: Element | null): boolean =>
|
||||
element instanceof HTMLInputElement ||
|
||||
element instanceof HTMLTextAreaElement ||
|
||||
@@ -150,6 +156,21 @@ const KeyPressListener: React.FC = () => {
|
||||
updateLocalStorage(!toggleUILeft, toggleUIRight);
|
||||
break;
|
||||
|
||||
case "Ctrl+Alt+S":
|
||||
setCreateNewVersion(true);
|
||||
setVersionHistoryVisible(true);
|
||||
setSubModule("properties");
|
||||
setActiveModule('builder');
|
||||
break;
|
||||
|
||||
case "Ctrl+H":
|
||||
if (!isPlaying) {
|
||||
setVersionHistoryVisible(true);
|
||||
setSubModule("properties");
|
||||
setActiveModule('builder');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -174,6 +195,7 @@ const KeyPressListener: React.FC = () => {
|
||||
clearComparisonProduct();
|
||||
setIsLogListVisible(false);
|
||||
setIsRenameMode(false);
|
||||
setSelectedComment(null);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -195,7 +217,7 @@ const KeyPressListener: React.FC = () => {
|
||||
handleBuilderShortcuts(keyCombination);
|
||||
|
||||
// Shortcut to enter play mode
|
||||
if (keyCombination === "Ctrl+P" && !toggleView) {
|
||||
if (keyCombination === "Ctrl+P" && !toggleView && !comparisonProduct) {
|
||||
setIsPlaying(true);
|
||||
}
|
||||
|
||||
@@ -211,7 +233,7 @@ const KeyPressListener: React.FC = () => {
|
||||
setShowShortcuts(!showShortcuts);
|
||||
}
|
||||
if (keyCombination === "U") {
|
||||
console.log("viewSceneLabels: ", viewSceneLabels);
|
||||
// console.log("viewSceneLabels: ", viewSceneLabels);
|
||||
setViewSceneLabels((prev) => !prev);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ function setTheme() {
|
||||
localStorage.setItem('theme', defaultTheme);
|
||||
}
|
||||
|
||||
// Function to toggle the theme
|
||||
// Function to toggle the theme
|
||||
export function toggleTheme() {
|
||||
const currentTheme: string | null = document.documentElement.getAttribute('data-theme');
|
||||
const newTheme: string = currentTheme === 'dark' ? 'light' : 'dark';
|
||||
|
||||
Reference in New Issue
Block a user