I got this code that works for the left mouse click on a button but how would I use to get the right mouse click signal:
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button-action), NULL);
A simple way to listen for any mouse clicks, be it left or right would be this:
g_signal_connect(
G_OBJECT(button)
"button-press-event",
G_CALLBACK(btn_press_callback),
NULL
);
Then, for the callback function:
gboolean btn_press_callback(GtkWidget *btn, GdkEventButton *event, gpointer userdata)
{
if (event->type == GDK_BUTTON_PRESS && event->button == 3)
{//3 is right mouse btn
//do stuff
return true;//or false
}
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
{//1 is left mouse btn
}
}
And so on... More info here.
some examples, using GTK+-2 but still useful, can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With