Help with Tooltip performance

Hi,

I have application that shows a map and on that map are scattered points representing Airports. (The map is drawn in a GLArea.) When a user hovers over a point of interest I show a tooltip with the airport name. This is working quite well using the following code

            self.gl_area.connect_query_tooltip(clone!(@weak self as view => @default-return false, move | _glarea, x, y, _kbm, tooltip | {
                match view.unproject(x as f64,y as f64) {
                    Ok(pos) => {
                        if let Some(airport) = view.find_location_for_point(pos) {
                            tooltip.set_text(Some(airport.get_name()));
                                true
                        } else {
                            tooltip.set_text(None);
                            false
                        }
                    }
                    Err(_) => {
                        tooltip.set_text(None);
                        false
                    }
                }
            }));

My problem is that the code behind find_location_for_point(pos) is quite expensive and is being executed much more frequently that I expected.
The documentation here: Gtk.Widget::query-tooltip says

This happens when the GtkWidget:has-tooltip property is TRUE and the hover timeout has expired with the cursor hovering “above” widget

But it seems that this is called for every mouse move event. Have I got this wrong or is there a way to lower the frequency of these calls.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.