Re: Which mouse button has been pressed?



you can connect "button_press_event" to your  button and find out which
button is clicked.

gtk_signal_connect_object (GTK_OBJECT (button), "button_press_event",
                               GTK_SIGNAL_FUNC(mouseevent_callback), NULL);

void mouseevent_callback(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
       /* left button of mouse is clicked */
       if(event->button == 1)
       {
          g_print("left click \n");
          return;
       }

       /* right button of mouse is clicked */
       if(event->button == 3)
       {
          g_print("right click \n");
          return;
       }

       /* both  buttons  of mouse is clicked */
       if(event->button == 2)
       {
          g_print("both buttons click \n");
          return;
       }
/* double click of the mouse */
       if(event->type == GDK_2BUTTON_PRESS)
       {
          g_print("double click \n");
          return;
       }
}



bombadil wanadoo es wrote:

El viernes 27 de septiembre, Satyajit Kanungo escribió:
You need to connect the "button_press_event" signal . With what you
are attching the signal ??

With "clicked" on GtkButton 0:)

Thank you very much. I think don't understand well signals theory.

                                                                David

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]