Skip to content

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

ParameterTypeDescription
clientXnumberHorizontal CSS client coordinate.
clientYnumberVertical CSS client coordinate.
target?TextmodeGridOptional grid to project onto.

Returns

GridPosition

Center-based grid coordinates.

Example

ts
const cell = t.projectClientToGrid(event.clientX, event.clientY);