The difference between TextWindowType::Text and TextWindowType::Widget (original) (raw)
February 4, 2025, 1:52pm 1
Can’t understand from documentation the difference.
I’m using following construction to detect TextTag
location for links in TextBuffer
primary_button_controller.connect_released({
move |_, _, window_x, window_y| {
let (buffer_x, buffer_y) = text_view.window_to_buffer_coords(
TextWindowType::Text,
window_x as i32,
window_y as i32,
);
if let Some(iter) = text_view.iter_at_location(buffer_x, buffer_y) {
for tag in iter.tags() {
// ..
Both variants are working, which one is better to choose in this case?
Thanks
gwillems February 4, 2025, 4:11pm 2
Hi,
GtkTextView have the possibility to add left/right/top/bottom “TextWindows” (typically a left one to display line numbers), that will shift and reduce the actual main text area (the GTK_TEXT_WINDOW_TEXT
one).
If you don’t use any left or top textwindow, then there will be no shift of the coordinates origins, so window_to_buffer_coords()
on GTK_TEXT_WINDOW_TEXT
and GTK_TEXT_WINDOW_WIDGET
will return the same buffer position.
In general, if you receive the (x,y) coordinates from a Gesture attached to the GtkTextView widget, then you should use GTK_TEXT_WINDOW_WIDGET
to be safe.
system (system) Closed March 6, 2025, 4:12pm 3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.