Add shift key support for reference cursors and update button text
This commit is contained in:
@@ -1118,6 +1118,7 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
}, []);
|
||||
|
||||
const [altPressed, setAltPressed] = useState(false);
|
||||
const [shiftPressed, setShiftPressed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const mainToolGroup = ToolGroupManager.getToolGroup(MAIN_TOOL_GROUP_ID);
|
||||
@@ -1144,23 +1145,32 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.altKey) setAltPressed(true);
|
||||
if (e.shiftKey) setShiftPressed(true);
|
||||
};
|
||||
const handleKeyUp = (e: KeyboardEvent) => {
|
||||
if (!e.altKey) setAltPressed(false);
|
||||
if (!e.shiftKey) setShiftPressed(false);
|
||||
};
|
||||
const handleBlur = () => {
|
||||
setAltPressed(false);
|
||||
setShiftPressed(false);
|
||||
};
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
window.addEventListener("keyup", handleKeyUp);
|
||||
window.addEventListener("blur", handleBlur);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
window.removeEventListener("keyup", handleKeyUp);
|
||||
window.removeEventListener("blur", handleBlur);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!altEnablesReferenceCursors) return;
|
||||
const mainToolGroup = ToolGroupManager.getToolGroup(MAIN_TOOL_GROUP_ID);
|
||||
if (!mainToolGroup) return;
|
||||
if (altPressed) {
|
||||
const modifierActive = shiftPressed || (altEnablesReferenceCursors && altPressed);
|
||||
|
||||
if (modifierActive) {
|
||||
if (!mainToolGroup.hasTool(ReferenceCursors.toolName)) {
|
||||
mainToolGroup.addTool(ReferenceCursors.toolName);
|
||||
}
|
||||
@@ -1171,7 +1181,7 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
mainToolGroup.setToolDisabled(ReferenceCursors.toolName);
|
||||
}
|
||||
}
|
||||
}, [altPressed, altEnablesReferenceCursors]);
|
||||
}, [altPressed, shiftPressed, altEnablesReferenceCursors]);
|
||||
|
||||
// Helper to apply all mouse tool bindings (normal or ctrl)
|
||||
const applyMouseToolBindings = useCallback(() => {
|
||||
@@ -4111,8 +4121,8 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
onClick={() => setAltEnablesReferenceCursors((prev) => !prev)}
|
||||
>
|
||||
{altEnablesReferenceCursors
|
||||
? "Disable Alt Key for Reference Cursors"
|
||||
: "Enable Alt Key for Reference Cursors"}
|
||||
? "Disable Alt Key for Reference Cursors (Shift always works)"
|
||||
: "Enable Alt Key for Reference Cursors (Shift always works)"}
|
||||
</button>
|
||||
<button
|
||||
style={{
|
||||
|
||||
Reference in New Issue
Block a user