Implement sidebar shortcut handling for visibility toggling; refactor existing shortcut logic for improved clarity
This commit is contained in:
parent
34aa9b9dec
commit
980d27c91f
|
@ -42,6 +42,7 @@ const KeyPressListener: React.FC = () => {
|
||||||
};
|
};
|
||||||
const module = modules[keyCombination];
|
const module = modules[keyCombination];
|
||||||
if (module && !toggleView) {
|
if (module && !toggleView) {
|
||||||
|
console.log("hi");
|
||||||
setActiveTool("cursor");
|
setActiveTool("cursor");
|
||||||
setActiveSubTool("cursor");
|
setActiveSubTool("cursor");
|
||||||
if (module === "market") setToggleUI(false, false);
|
if (module === "market") setToggleUI(false, false);
|
||||||
|
@ -106,6 +107,29 @@ const KeyPressListener: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const handleSidebarShortcuts = (key: string) => {
|
||||||
|
if (activeModule !== "market") {
|
||||||
|
if (key === "Ctrl+\\") {
|
||||||
|
if (toggleUILeft === toggleUIRight) {
|
||||||
|
setToggleUI(!toggleUILeft, !toggleUIRight);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setToggleUI(true, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key === "Ctrl+]") {
|
||||||
|
setToggleUI(toggleUILeft, !toggleUIRight);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key === "Ctrl+[") {
|
||||||
|
setToggleUI(!toggleUILeft, toggleUIRight);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const handleKeyPress = (event: KeyboardEvent) => {
|
const handleKeyPress = (event: KeyboardEvent) => {
|
||||||
if (isTextInput(document.activeElement)) return;
|
if (isTextInput(document.activeElement)) return;
|
||||||
|
|
||||||
|
@ -114,28 +138,8 @@ const KeyPressListener: React.FC = () => {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (keyCombination === "Ctrl+\\") {
|
// Shortcuts specific for sidebar visibility toggle and others specific to sidebar if added
|
||||||
if (toggleUILeft === toggleUIRight) {
|
handleSidebarShortcuts(keyCombination);
|
||||||
setToggleUI(!toggleUILeft, !toggleUIRight);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
activeModule !== "market" && setToggleUI(true, true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (keyCombination === "Ctrl+]") {
|
|
||||||
if (activeModule !== "market") {
|
|
||||||
setToggleUI(toggleUILeft, !toggleUIRight);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (keyCombination === "Ctrl+[") {
|
|
||||||
if (activeModule !== "market") {
|
|
||||||
setToggleUI(!toggleUILeft, toggleUIRight);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active module selection (builder, simulation, etc.)
|
// Active module selection (builder, simulation, etc.)
|
||||||
handleModuleSwitch(keyCombination);
|
handleModuleSwitch(keyCombination);
|
||||||
// Common editing tools: cursor | delete | free-hand
|
// Common editing tools: cursor | delete | free-hand
|
||||||
|
|
Loading…
Reference in New Issue