Gtk.TextView.prototype.get_iter_at_position

function get_iter_at_position(x:Number, y:Number):void {
    // Gjs wrapper for gtk_text_view_get_iter_at_position()
}

Retrieves the iterator pointing to the character at buffer coordinates x and y. Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with Gtk.window_to_buffer_coords.

Note that this is different from Gtk.TextView.prototype.get_iter_at_location, which returns cursor locations, i.e. positions <emphasis>between</emphasis> characters.

Since 2.6

x

x position, in buffer coordinates

y

y position, in buffer coordinates