textmode.js / Textmodifier / projectClientToGrid
Method: projectClientToGrid()
ts
projectClientToGrid(
clientX,
clientY,
target?): GridPosition;Project CSS viewport/client coordinates into a textmode grid.
When target is omitted, the topmost visible layer grid is used, falling back to the base grid. Coordinates outside an initialized grid are returned as Number.NEGATIVE_INFINITY on both axes. This is grid projection, not transformed visual hit-testing.
Parameters
| Parameter | Type | Description |
|---|---|---|
clientX | number | Horizontal CSS client coordinate. |
clientY | number | Vertical CSS client coordinate. |
target? | TextmodeGrid | Optional grid to project onto. |
Returns
Center-based grid coordinates.
Example
ts
const cell = t.projectClientToGrid(event.clientX, event.clientY);