Package: gtk

Function gtk:entry-layout-offsets

Lambda List

gtk:entry-layout-offsets (entry)

Syntax

(gtk:entry-layout-offsets entry) => x, y

Arguments

entry -- a gtk:entry widget
x -- an integer for the x offset of the Pango layout
y -- an integer for the y offset of the Pango layout

Details

Obtains the position of the Pango layout used to render text in the entry, in widget coordinates. Useful if you want to line up the text in an entry with some other text, for example, when using the entry to implement editable cells in a sheet widget. Also useful to convert mouse events into coordinates inside the Pango layout, for example, to take some action if some part of the entry text is clicked.

Note that as the user scrolls around in the entry the offsets will change. You will need to connect to the "notify::scroll-offset" signal to track this. Remember when using the pango:layout functions you need to convert to and from pixels using the pango:pixels function or the pango:+scale+ constant.

Keep in mind that the layout text may contain a preedit string, so the gtk:entry-layout-index-to-text-index and gtk:entry-text-index-to-layout-index functions are needed to convert byte indices in the layout to byte indices in the entry contents.
 

See also

2025-07-09