Documentation / @finchart/core / InputEvent
Type Alias: InputEvent
InputEvent = {
button?:number;point:Point;pointerId:number;type:"pointerdown"|"pointermove"|"pointerup"; } | {point:Point;pointerId:number;type:"pointercancel"; } | {deltaY:number;point:Point;type:"wheel"; } | {point:Point;type:"dblclick"; } | {point:Point;type:"contextmenu"; } | {key:string;type:"keydown"; }
Defined in: packages/core/src/interaction/input-router.ts:16
요소 기준 좌표로 정규화된 입력 하나. DOM 이벤트가 아니라 순수 데이터다 — 소비자가 DOM을 몰라도 되고, headless 호스트가 입력을 합성할 수 있다.
pointerId를 지금 싣는 이유: 핀치는 포인터 둘을 동시에 추적한다. 나중에 더하면 모든 소비자의 시그니처가 흔들린다.
Union Members
Type Literal
{ button?: number; point: Point; pointerId: number; type: "pointerdown" | "pointermove" | "pointerup"; }
button?
optionalbutton?:number
누른 버튼 (DOM PointerEvent.button과 같은 번호: 0 주, 1 휠, 2 보조). 없으면 주 버튼이다 — 합성 입력이 안 적어도 오늘과 같은 뜻이다.
우클릭 드래그 오작동을 막는 필드다 — 이게 없으면 선 위에서 우클릭할 때 버튼을 누른 동안의 손떨림이 그대로 드래그로 읽혀 도형이 밀린다. 선택 필드라 배포 후에 추가해도 안 읽는 소비자는 그대로 동작한다(새 변형 추가나 기존 필드 뜻 변경과 다르다).
point
point:
Point
pointerId
pointerId:
number
type
type:
"pointerdown"|"pointermove"|"pointerup"
Type Literal
{ point: Point; pointerId: number; type: "pointercancel"; }
제스처가 중단됐다 — 뗀 것이 아니다.
브라우저가 포인터를 회수하는 자리들이다: 태블릿의 손바닥 인식, OS 제스처, 스크롤 인수, 창 전환. up과 cancel은 도구에게 정반대다 — up으로 접으면 반쯤 끌린 도형이 취소 시점에 그대로 커밋된다.
선택 필드가 아니라 새 변형인 이유: 선택 필드는 안 읽는 소비자에게 옛 버그(뗌인데 뗌이 아닌 것)를 기본으로 상속시킨다. 새 변형이면 exhaustive switch가 컴파일에서 묻는다.
dom은 안 먹는 소비자를 위해 이것을 pan/제스처 정리에도 쓴다.
Type Literal
{ deltaY: number; point: Point; type: "wheel"; }
Type Literal
{ point: Point; type: "dblclick"; }
Type Literal
{ point: Point; type: "contextmenu"; }
우클릭.
InputEvent는 공개 유니언이고 소비자가 exhaustive switch로 소비하므로, 배포 후에 변형을 더하면 breaking이다.
레시피(@finchart/tools가 이 문을 쓰는 법):
plot.on("contextmenu", ({ position }) => {
const target = tools.selection(); // 커서 아래 드로잉, 없으면 null
openMenu(position, target);
});도구함은 우클릭에 고르되 먹지 않는다 — 맞히면 선택하고 빗나가면 선택을 푼다. false를 돌려주므로 plot.contextMenu(point)가 그대로 울려 앱이 자기 메뉴를 연다.
포인터 변형의 button이 이 제스처의 짝이다 — 그것 없이는 우클릭 앞에 오는 pointerdown이 드래그를 시작해 드로잉이 움직인다.
캡처는 없다 — 우클릭에 "드래그를 가져간다"에 해당하는 것이 없다.
Type Literal
{ key: string; type: "keydown"; }
수정키 없는 키 하나 (선택·삭제·취소가 이 길로 온다 — 2026-08-10 리뷰). point가 없다 — 키는 커서가 아니라 포커스의 것이다. 캡처도 없다: "드래그를 가져간다"에 해당하는 것이 키에는 없어서, wheel처럼 스택을 한 번 지날 뿐이다.