mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-25 08:07:41 +03:00
Refactor prevent default to not require separate input
This commit is contained in:
parent
f9db12e119
commit
1f463e7e5d
@ -70,7 +70,10 @@ export default function ExportCard({
|
|||||||
(editName.update?.length ?? 0) > 0
|
(editName.update?.length ?? 0) > 0
|
||||||
) {
|
) {
|
||||||
submitRename();
|
submitRename();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -109,6 +109,7 @@ export default function ReviewCard({
|
|||||||
|
|
||||||
useKeyboardListener(["Shift"], (_, modifiers) => {
|
useKeyboardListener(["Shift"], (_, modifiers) => {
|
||||||
bypassDialogRef.current = modifiers.shift;
|
bypassDialogRef.current = modifiers.shift;
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleDelete = useCallback(() => {
|
const handleDelete = useCallback(() => {
|
||||||
|
|||||||
@ -75,6 +75,7 @@ export default function ReviewActionGroup({
|
|||||||
|
|
||||||
useKeyboardListener(["Shift"], (_, modifiers) => {
|
useKeyboardListener(["Shift"], (_, modifiers) => {
|
||||||
setBypassDialog(modifiers.shift);
|
setBypassDialog(modifiers.shift);
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleDelete = useCallback(() => {
|
const handleDelete = useCallback(() => {
|
||||||
|
|||||||
@ -62,6 +62,7 @@ export default function SearchActionGroup({
|
|||||||
|
|
||||||
useKeyboardListener(["Shift"], (_, modifiers) => {
|
useKeyboardListener(["Shift"], (_, modifiers) => {
|
||||||
setBypassDialog(modifiers.shift);
|
setBypassDialog(modifiers.shift);
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleDelete = useCallback(() => {
|
const handleDelete = useCallback(() => {
|
||||||
|
|||||||
@ -83,7 +83,7 @@ export default function PtzControlPanel({
|
|||||||
],
|
],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (modifiers.repeat || !key) {
|
if (modifiers.repeat || !key) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(key)) {
|
if (["1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(key)) {
|
||||||
@ -95,34 +95,36 @@ export default function PtzControlPanel({
|
|||||||
) {
|
) {
|
||||||
sendPtz(`preset_${ptz.presets[presetNumber - 1]}`);
|
sendPtz(`preset_${ptz.presets[presetNumber - 1]}`);
|
||||||
}
|
}
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
sendPtz("STOP");
|
sendPtz("STOP");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
sendPtz("MOVE_LEFT");
|
sendPtz("MOVE_LEFT");
|
||||||
break;
|
return true;
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
sendPtz("MOVE_RIGHT");
|
sendPtz("MOVE_RIGHT");
|
||||||
break;
|
return true;
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
sendPtz("MOVE_UP");
|
sendPtz("MOVE_UP");
|
||||||
break;
|
return true;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
sendPtz("MOVE_DOWN");
|
sendPtz("MOVE_DOWN");
|
||||||
break;
|
return true;
|
||||||
case "+":
|
case "+":
|
||||||
sendPtz(modifiers.shift ? "FOCUS_IN" : "ZOOM_IN");
|
sendPtz(modifiers.shift ? "FOCUS_IN" : "ZOOM_IN");
|
||||||
break;
|
return true;
|
||||||
case "-":
|
case "-":
|
||||||
sendPtz(modifiers.shift ? "FOCUS_OUT" : "ZOOM_OUT");
|
sendPtz(modifiers.shift ? "FOCUS_OUT" : "ZOOM_OUT");
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -175,6 +175,8 @@ export default function ReviewDetailDialog({
|
|||||||
if (key == "Esc" && modifiers.down && !modifiers.repeat) {
|
if (key == "Esc" && modifiers.down && !modifiers.repeat) {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const Overlay = isDesktop ? Sheet : MobilePage;
|
const Overlay = isDesktop ? Sheet : MobilePage;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ export function GenericVideoPlayer({
|
|||||||
["ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", " ", "f", "m"],
|
["ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", " ", "f", "m"],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (!modifiers.down || modifiers.repeat) {
|
if (!modifiers.down || modifiers.repeat) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -92,6 +92,8 @@ export function GenericVideoPlayer({
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ export default function VideoControls({
|
|||||||
const onKeyboardShortcut = useCallback(
|
const onKeyboardShortcut = useCallback(
|
||||||
(key: string | null, modifiers: KeyModifiers) => {
|
(key: string | null, modifiers: KeyModifiers) => {
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -174,6 +174,8 @@ export default function VideoControls({
|
|||||||
onPlayPause(!isPlaying);
|
onPlayPause(!isPlaying);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
// only update when preview only changes
|
// only update when preview only changes
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|||||||
@ -9,8 +9,7 @@ export type KeyModifiers = {
|
|||||||
|
|
||||||
export default function useKeyboardListener(
|
export default function useKeyboardListener(
|
||||||
keys: string[],
|
keys: string[],
|
||||||
listener: (key: string | null, modifiers: KeyModifiers) => void,
|
listener: (key: string | null, modifiers: KeyModifiers) => boolean,
|
||||||
preventDefault: boolean = true,
|
|
||||||
) {
|
) {
|
||||||
const keyDownListener = useCallback(
|
const keyDownListener = useCallback(
|
||||||
(e: KeyboardEvent) => {
|
(e: KeyboardEvent) => {
|
||||||
@ -27,13 +26,13 @@ export default function useKeyboardListener(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (keys.includes(e.key)) {
|
if (keys.includes(e.key)) {
|
||||||
|
const preventDefault = listener(e.key, modifiers);
|
||||||
if (preventDefault) e.preventDefault();
|
if (preventDefault) e.preventDefault();
|
||||||
listener(e.key, modifiers);
|
|
||||||
} else if (e.key === "Shift" || e.key === "Control" || e.key === "Meta") {
|
} else if (e.key === "Shift" || e.key === "Control" || e.key === "Meta") {
|
||||||
listener(null, modifiers);
|
listener(null, modifiers);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[keys, listener, preventDefault],
|
[keys, listener],
|
||||||
);
|
);
|
||||||
|
|
||||||
const keyUpListener = useCallback(
|
const keyUpListener = useCallback(
|
||||||
|
|||||||
@ -117,7 +117,7 @@ function Exports() {
|
|||||||
["ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
["ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -146,6 +146,8 @@ function Exports() {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -117,8 +117,6 @@ export default function FaceLibrary() {
|
|||||||
const [addFace, setAddFace] = useState(false);
|
const [addFace, setAddFace] = useState(false);
|
||||||
|
|
||||||
// input focus for keyboard shortcuts
|
// input focus for keyboard shortcuts
|
||||||
const [inputFocused, setInputFocused] = useState(false);
|
|
||||||
|
|
||||||
const onUploadImage = useCallback(
|
const onUploadImage = useCallback(
|
||||||
(file: File) => {
|
(file: File) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@ -275,7 +273,7 @@ export default function FaceLibrary() {
|
|||||||
["a", "Escape", "ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
["a", "Escape", "ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -288,23 +286,25 @@ export default function FaceLibrary() {
|
|||||||
...(pageToggle === "train" ? trainImages : faceImages),
|
...(pageToggle === "train" ? trainImages : faceImages),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Escape":
|
case "Escape":
|
||||||
setSelectedFaces([]);
|
setSelectedFaces([]);
|
||||||
break;
|
return true;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: 100,
|
top: 100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -100,
|
top: -100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageDown":
|
case "PageDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: contentRef.current.clientHeight / 2,
|
top: contentRef.current.clientHeight / 2,
|
||||||
@ -316,10 +316,11 @@ export default function FaceLibrary() {
|
|||||||
top: -contentRef.current.clientHeight / 2,
|
top: -contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
!inputFocused,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -446,7 +447,6 @@ export default function FaceLibrary() {
|
|||||||
selectedFaces={selectedFaces}
|
selectedFaces={selectedFaces}
|
||||||
onClickFaces={onClickFaces}
|
onClickFaces={onClickFaces}
|
||||||
onRefresh={refreshFaces}
|
onRefresh={refreshFaces}
|
||||||
setInputFocused={setInputFocused}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<FaceGrid
|
<FaceGrid
|
||||||
@ -649,7 +649,6 @@ type TrainingGridProps = {
|
|||||||
selectedFaces: string[];
|
selectedFaces: string[];
|
||||||
onClickFaces: (images: string[], ctrl: boolean) => void;
|
onClickFaces: (images: string[], ctrl: boolean) => void;
|
||||||
onRefresh: () => void;
|
onRefresh: () => void;
|
||||||
setInputFocused: React.Dispatch<React.SetStateAction<boolean>>;
|
|
||||||
};
|
};
|
||||||
function TrainingGrid({
|
function TrainingGrid({
|
||||||
config,
|
config,
|
||||||
@ -659,7 +658,6 @@ function TrainingGrid({
|
|||||||
selectedFaces,
|
selectedFaces,
|
||||||
onClickFaces,
|
onClickFaces,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
setInputFocused,
|
|
||||||
}: TrainingGridProps) {
|
}: TrainingGridProps) {
|
||||||
const { t } = useTranslation(["views/faceLibrary"]);
|
const { t } = useTranslation(["views/faceLibrary"]);
|
||||||
|
|
||||||
@ -734,7 +732,7 @@ function TrainingGrid({
|
|||||||
setSimilarity={undefined}
|
setSimilarity={undefined}
|
||||||
setSearchPage={setDialogTab}
|
setSearchPage={setDialogTab}
|
||||||
setSearch={(search) => setSelectedEvent(search as unknown as Event)}
|
setSearch={(search) => setSelectedEvent(search as unknown as Event)}
|
||||||
setInputFocused={setInputFocused}
|
setInputFocused={() => {}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -56,14 +56,16 @@ function Live() {
|
|||||||
|
|
||||||
useKeyboardListener(["f"], (key, modifiers) => {
|
useKeyboardListener(["f"], (key, modifiers) => {
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "f":
|
case "f":
|
||||||
toggleFullscreen();
|
toggleFullscreen();
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// document title
|
// document title
|
||||||
|
|||||||
@ -337,7 +337,7 @@ function Logs() {
|
|||||||
["PageDown", "PageUp", "ArrowDown", "ArrowUp"],
|
["PageDown", "PageUp", "ArrowDown", "ArrowUp"],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (!key || !modifiers.down || !lazyLogWrapperRef.current) {
|
if (!key || !modifiers.down || !lazyLogWrapperRef.current) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const container =
|
const container =
|
||||||
@ -346,7 +346,7 @@ function Logs() {
|
|||||||
const logLineHeight = container?.querySelector(".log-line")?.clientHeight;
|
const logLineHeight = container?.querySelector(".log-line")?.clientHeight;
|
||||||
|
|
||||||
if (!logLineHeight) {
|
if (!logLineHeight) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollAmount = key.includes("Page")
|
const scrollAmount = key.includes("Page")
|
||||||
@ -354,6 +354,7 @@ function Logs() {
|
|||||||
: logLineHeight;
|
: logLineHeight;
|
||||||
const direction = key.includes("Down") ? 1 : -1;
|
const direction = key.includes("Down") ? 1 : -1;
|
||||||
container?.scrollBy({ top: scrollAmount * direction });
|
container?.scrollBy({ top: scrollAmount * direction });
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -237,13 +237,13 @@ export default function ModelTrainingView({ model }: ModelTrainingViewProps) {
|
|||||||
useKeyboardListener(
|
useKeyboardListener(
|
||||||
["a", "Escape", "ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
["a", "Escape", "ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (modifiers.repeat || !modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "a":
|
case "a":
|
||||||
if (modifiers.ctrl) {
|
if (modifiers.ctrl && !modifiers.repeat) {
|
||||||
if (selectedImages.length) {
|
if (selectedImages.length) {
|
||||||
setSelectedImages([]);
|
setSelectedImages([]);
|
||||||
} else {
|
} else {
|
||||||
@ -253,36 +253,39 @@ export default function ModelTrainingView({ model }: ModelTrainingViewProps) {
|
|||||||
: dataset?.[pageToggle] || []),
|
: dataset?.[pageToggle] || []),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Escape":
|
case "Escape":
|
||||||
setSelectedImages([]);
|
setSelectedImages([]);
|
||||||
break;
|
return true;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: 100,
|
top: 100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -100,
|
top: -100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageDown":
|
case "PageDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: contentRef.current.clientHeight / 2,
|
top: contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageUp":
|
case "PageUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -contentRef.current.clientHeight / 2,
|
top: -contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -654,13 +654,14 @@ function DetectionReview({
|
|||||||
["a", "r", "ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
["a", "r", "ArrowDown", "ArrowUp", "PageDown", "PageUp"],
|
||||||
(key, modifiers) => {
|
(key, modifiers) => {
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "a":
|
case "a":
|
||||||
if (modifiers.ctrl && !modifiers.repeat) {
|
if (modifiers.ctrl && !modifiers.repeat) {
|
||||||
onSelectAllReviews();
|
onSelectAllReviews();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "r":
|
case "r":
|
||||||
@ -673,32 +674,34 @@ function DetectionReview({
|
|||||||
});
|
});
|
||||||
setSelectedReviews([]);
|
setSelectedReviews([]);
|
||||||
}
|
}
|
||||||
break;
|
return true;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: 100,
|
top: 100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -100,
|
top: -100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageDown":
|
case "PageDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: contentRef.current.clientHeight / 2,
|
top: contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageUp":
|
case "PageUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -contentRef.current.clientHeight / 2,
|
top: -contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -309,21 +309,25 @@ export default function LiveCameraView({
|
|||||||
|
|
||||||
useKeyboardListener(["m"], (key, modifiers) => {
|
useKeyboardListener(["m"], (key, modifiers) => {
|
||||||
if (!modifiers.down) {
|
if (!modifiers.down) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "m":
|
case "m":
|
||||||
if (supportsAudioOutput) {
|
if (supportsAudioOutput) {
|
||||||
setAudio(!audio);
|
setAudio(!audio);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "t":
|
case "t":
|
||||||
if (supports2WayTalk) {
|
if (supports2WayTalk) {
|
||||||
setMic(!mic);
|
setMic(!mic);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// layout state
|
// layout state
|
||||||
|
|||||||
@ -308,14 +308,19 @@ export default function SearchView({
|
|||||||
|
|
||||||
const onKeyboardShortcut = useCallback(
|
const onKeyboardShortcut = useCallback(
|
||||||
(key: string | null, modifiers: KeyModifiers) => {
|
(key: string | null, modifiers: KeyModifiers) => {
|
||||||
if (!modifiers.down || !uniqueResults || inputFocused) {
|
if (inputFocused) {
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modifiers.down || !uniqueResults) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "a":
|
case "a":
|
||||||
if (modifiers.ctrl && !modifiers.repeat) {
|
if (modifiers.ctrl && !modifiers.repeat) {
|
||||||
onSelectAllObjects();
|
onSelectAllObjects();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
@ -334,7 +339,7 @@ export default function SearchView({
|
|||||||
|
|
||||||
setSearchDetail(uniqueResults[newIndex]);
|
setSearchDetail(uniqueResults[newIndex]);
|
||||||
}
|
}
|
||||||
break;
|
return true;
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
if (uniqueResults.length > 0) {
|
if (uniqueResults.length > 0) {
|
||||||
const currentIndex = searchDetail
|
const currentIndex = searchDetail
|
||||||
@ -350,32 +355,34 @@ export default function SearchView({
|
|||||||
|
|
||||||
setSearchDetail(uniqueResults[newIndex]);
|
setSearchDetail(uniqueResults[newIndex]);
|
||||||
}
|
}
|
||||||
break;
|
return true;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: 100,
|
top: 100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -100,
|
top: -100,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageDown":
|
case "PageDown":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: contentRef.current.clientHeight / 2,
|
top: contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
case "PageUp":
|
case "PageUp":
|
||||||
contentRef.current?.scrollBy({
|
contentRef.current?.scrollBy({
|
||||||
top: -contentRef.current.clientHeight / 2,
|
top: -contentRef.current.clientHeight / 2,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
[uniqueResults, inputFocused, onSelectAllObjects, searchDetail],
|
[uniqueResults, inputFocused, onSelectAllObjects, searchDetail],
|
||||||
);
|
);
|
||||||
@ -391,7 +398,6 @@ export default function SearchView({
|
|||||||
"PageUp",
|
"PageUp",
|
||||||
],
|
],
|
||||||
onKeyboardShortcut,
|
onKeyboardShortcut,
|
||||||
!inputFocused,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// scroll into view
|
// scroll into view
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user