MCPcopy
hub / github.com/codeaashu/claude-code / dispatchClick

Function dispatchClick

src/ink/hit-test.ts:49–89  ·  view source on GitHub ↗
(
  root: DOMElement,
  col: number,
  row: number,
  cellIsBlank = false,
)

Source from the content-addressed store, hash-verified

47 * true if at least one onClick handler fired.
48 */
49export function dispatchClick(
50 root: DOMElement,
51 col: number,
52 row: number,
53 cellIsBlank = false,
54): boolean {
55 let target: DOMElement | undefined = hitTest(root, col, row) ?? undefined
56 if (!target) return false
57
58 // Click-to-focus: find the closest focusable ancestor and focus it.
59 // root is always ink-root, which owns the FocusManager.
60 if (root.focusManager) {
61 let focusTarget: DOMElement | undefined = target
62 while (focusTarget) {
63 if (typeof focusTarget.attributes['tabIndex'] === 'number') {
64 root.focusManager.handleClickFocus(focusTarget)
65 break
66 }
67 focusTarget = focusTarget.parentNode
68 }
69 }
70 const event = new ClickEvent(col, row, cellIsBlank)
71 let handled = false
72 while (target) {
73 const handler = target._eventHandlers?.onClick as
74 | ((event: ClickEvent) => void)
75 | undefined
76 if (handler) {
77 handled = true
78 const rect = nodeCache.get(target)
79 if (rect) {
80 event.localCol = col - rect.x
81 event.localRow = row - rect.y
82 }
83 handler(event)
84 if (event.didStopImmediatePropagation()) return true
85 }
86 target = target.parentNode
87 }
88 return handled
89}
90
91/**
92 * Fire onMouseEnter/onMouseLeave as the pointer moves. Like DOM

Callers 1

dispatchClickMethod · 0.85

Calls 5

hitTestFunction · 0.85
handleClickFocusMethod · 0.80
getMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected