Package: pango

Function pango:layout-xy-to-index

Lambda List

pango:layout-xy-to-index (layout x y)

Syntax

(pango:layout-xy-to-index layout x y) => index, trailing

Arguments

layout -- a pango:layout object
x -- an integer for the x offset in Pango units from the left edge of the Pango layout
y -- an integer for the y offset in Pango units from the top edge of the Pango layout
index -- an integer with the calculated byte index
trailing -- an integer indicating where in the grapheme the user clicked, it will either be zero, or the number of characters in the grapheme, 0 represents the trailing edge of the grapheme

Details

Converts from x and y position within a Pango layout to the byte index of the character at that logical position. If the y position is not inside the Pango layout, the closest position is chosen (the position will be clamped inside the Pango layout). If the x position is not within the Pango layout, then the start or the end of the line is chosen as described for the pango:layout-line-x-to-index function. If either the x or y positions were not inside the Pango layout, then the function returns nil.
 

See also

2025-2-15