mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Fix number overlay hotkeys conflict with screenshot in macos (#222)
This commit is contained in:
parent
961502916b
commit
688ed8a870
@ -360,28 +360,47 @@ function genericClose(tabId: string) {
|
||||
services.ObjectService.DeleteBlock(activeBlockId);
|
||||
}
|
||||
|
||||
const simpleCmdShiftAtom = jotai.atom(false);
|
||||
const simpleControlShiftAtom = jotai.atom(false);
|
||||
|
||||
const AppKeyHandlers = () => {
|
||||
const tabId = jotai.useAtomValue(atoms.activeTabId);
|
||||
|
||||
function setControlShift() {
|
||||
globalStore.set(simpleControlShiftAtom, true);
|
||||
setTimeout(() => {
|
||||
const simpleState = globalStore.get(simpleControlShiftAtom);
|
||||
if (simpleState) {
|
||||
globalStore.set(atoms.controlShiftDelayAtom, true);
|
||||
}
|
||||
}, 400);
|
||||
}
|
||||
|
||||
function unsetControlShift() {
|
||||
globalStore.set(simpleControlShiftAtom, false);
|
||||
globalStore.set(atoms.controlShiftDelayAtom, false);
|
||||
}
|
||||
|
||||
function handleKeyUp(event: KeyboardEvent) {
|
||||
const waveEvent = keyutil.adaptFromReactOrNativeKeyEvent(event);
|
||||
if (waveEvent.key == "Control" || waveEvent.key == "Shift") {
|
||||
globalStore.set(simpleCmdShiftAtom, false);
|
||||
globalStore.set(atoms.cmdShiftDelayAtom, false);
|
||||
if (waveEvent.key === "Control" || waveEvent.key === "Shift") {
|
||||
unsetControlShift();
|
||||
}
|
||||
if (waveEvent.key == "Meta") {
|
||||
if (waveEvent.control && waveEvent.shift) {
|
||||
setControlShift();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
|
||||
if ((waveEvent.key == "Control" || waveEvent.key == "Shift") && waveEvent.control && waveEvent.shift) {
|
||||
globalStore.set(simpleCmdShiftAtom, true);
|
||||
setTimeout(() => {
|
||||
const simpleState = globalStore.get(simpleCmdShiftAtom);
|
||||
if (simpleState) {
|
||||
globalStore.set(atoms.cmdShiftDelayAtom, true);
|
||||
if (waveEvent.key === "Control" || waveEvent.key === "Shift" || waveEvent.key === "Meta") {
|
||||
if (waveEvent.control && waveEvent.shift && !waveEvent.meta) {
|
||||
// Set the control and shift without the Meta key
|
||||
setControlShift();
|
||||
} else {
|
||||
// Unset if Meta is pressed
|
||||
unsetControlShift();
|
||||
}
|
||||
}, 400);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ function BlockNum({ blockId }: { blockId: string }) {
|
||||
}
|
||||
|
||||
const BlockMask = ({ blockId, preview, isFocused }: { blockId: string; preview: boolean; isFocused: boolean }) => {
|
||||
const isLayoutMode = jotai.useAtomValue(atoms.cmdShiftDelayAtom);
|
||||
const isLayoutMode = jotai.useAtomValue(atoms.controlShiftDelayAtom);
|
||||
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", blockId));
|
||||
|
||||
const style: React.CSSProperties = {};
|
||||
|
@ -103,7 +103,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
||||
}
|
||||
return windowData.activetabid;
|
||||
});
|
||||
const cmdShiftDelayAtom = jotai.atom(false);
|
||||
const controlShiftDelayAtom = jotai.atom(false);
|
||||
const updateStatusAtom = jotai.atom<UpdaterStatus>("up-to-date") as jotai.PrimitiveAtom<UpdaterStatus>;
|
||||
try {
|
||||
globalStore.set(updateStatusAtom, getApi().getUpdaterStatus());
|
||||
@ -126,7 +126,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
||||
tabAtom: tabAtom,
|
||||
activeTabId: activeTabIdAtom,
|
||||
isFullScreen: isFullScreenAtom,
|
||||
cmdShiftDelayAtom: cmdShiftDelayAtom,
|
||||
controlShiftDelayAtom: controlShiftDelayAtom,
|
||||
updaterStatusAtom: updateStatusAtom,
|
||||
};
|
||||
}
|
||||
|
2
frontend/types/custom.d.ts
vendored
2
frontend/types/custom.d.ts
vendored
@ -16,7 +16,7 @@ declare global {
|
||||
tabAtom: jotai.Atom<Tab>; // driven from WOS
|
||||
activeTabId: jotai.Atom<string>; // derrived from windowDataAtom
|
||||
isFullScreen: jotai.PrimitiveAtom<boolean>;
|
||||
cmdShiftDelayAtom: jotai.PrimitiveAtom<boolean>;
|
||||
controlShiftDelayAtom: jotai.PrimitiveAtom<boolean>;
|
||||
updaterStatusAtom: jotai.PrimitiveAtom<UpdaterStatus>;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user