Is there a way to ignore double and triple clicks/presses in in a GTK application?


I am working on an application that normally runs on touchscreens. Right now there is a button (we’ll call it button A) that when clicked shows a new row of buttons. The user can keep clicking button A to toggle between two different sets of buttons as they don’t all fit on the screen at once.

The problem is that if someone clicks the button with a double or triple click on accident it creates a confusing and annoying phenomena where the next press/click given to the button doesn’t do anything.

My idea to why this is occurring is because button press event seem to increment within a short time period to make up double and triple clicks. I think the handler is interpreting this in a weird way and causing this annoying phenomenon to occur.

So my question is this. Is there any way to turn off interpretation of double and triple clicks. I do not need double or triple clicks. I want every single press of the button to be interpreted as a single click/press. I can post some code if needed, but I wasn’t really sure what code I would need to post here. Also, I just generally want to know if this sort of thing is possible.


I had a similar problem. Are you using GTK4?
The button click event controller callback is passed the number of clicks. I used it to filter unwanted double and triple clicks

on_glarea_widget_click(GtkGestureClick *controller,
                                        gint n_press,
                                        G_GNUC_UNUSED gdouble x,
                                        G_GNUC_UNUSED gdouble y,
                                        G_GNUC_UNUSED gpointer user_data)
1 Like

Sorry I’m getting back to this thread so late. I am using GTK3 actually. Ill try to see if I can do something similar. I took a break from this issue for a week so nothing new yet but if I discover something Ill post it.

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