MCPcopy
hub / github.com/CapSoftware/Cap / onPick

Function onPick

apps/desktop/src/routes/editor/ConfigSidebar.tsx:4518–4539  ·  view source on GitHub ↗
(downEvent: MouseEvent)

Source from the content-addressed store, hash-verified

4516 const { projectHistory } = useEditorContext();
4517
4518 const onPick = (downEvent: MouseEvent) => {
4519 downEvent.preventDefault();
4520 const bounds = downEvent.currentTarget as HTMLElement;
4521 const rect = bounds.getBoundingClientRect();
4522 const resumeHistory = projectHistory.pause();
4523 const apply = (e: MouseEvent) => {
4524 props.onChange({
4525 x: Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)),
4526 y: Math.max(0, Math.min(1, (e.clientY - rect.top) / rect.height)),
4527 });
4528 };
4529 apply(downEvent);
4530 createRoot((dispose) =>
4531 createEventListenerMap(window, {
4532 mousemove: apply,
4533 mouseup: () => {
4534 resumeHistory();
4535 dispose();
4536 },
4537 }),
4538 );
4539 };
4540
4541 return (
4542 <div

Callers

nothing calls this directly

Calls 3

applyFunction · 0.85
disposeFunction · 0.85
pauseMethod · 0.80

Tested by

no test coverage detected