Function

CTLineGetStringIndexForPosition(_:_:)

Performs hit testing.

Declaration

func CTLineGetStringIndexForPosition(_ line: CTLine, _ position: CGPoint) -> CFIndex

Parameters

line

The line being examined.

position

The location of the mouse click relative to the line's origin.

Return Value

The string index for the position, or if the line does not support string access, kCFNotFound. Relative to the line's string range, this value can be no less than the first string index and no greater than the last string index plus 1.

Discussion

This function can be used to determine the string index for a mouse click or other event. This string index corresponds to the character before which the next character should be inserted. This determination is made by analyzing the string from which a typesetter was created and the corresponding glyphs as embodied by a particular line.

See Also

Getting Line Positioning

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software