Re: GTK and mouse



You must connect an event handler on your widget
for button press. Then in the GdkEvent you get in the
callback function, you can retrieve the mouse coordinate
(relative to the widget)
The following example is for GTK2.

g_signal_connect (GTK_OBJECT (mywidget),
                    "button_press_event",
                    G_CALLBACK (my_event_handler),
                    NULL);

and in your callback 'my_event_handler':

static gboolean
my_event_handler(GtkWidget *widget,
                 GdkEventButton *event,
                 gpointer user_data)
{
    if(event->type == GDK_BUTTON_PRESS)
    {
        if(event->button == 3)//right button
        {
           event->x;//is the x coordinate
           event->y;//is the y coordinate

...do the job here
and return TRUE


Pascal

> ---------- Initial message -----------
>
> From    : gtk-list-admin gnome org
> To      : <gtk-list gnome org>
> Cc      :
> Date    : Thu, 2 May 2002 11:26:51 +0200
> Subject : GTK and mouse
>
> Hi,
>
> I want to stick up the coordinates of the mouse when I
pressed on the right
> click. Can you help me, please ?
>
> Romain
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
--------------
Profitez des 2 offres exceptionnelles Tiscali !
"Internet Gratuit le Jour" et "Modem ADSL remboursé"
Cliquez ici, http://register.tiscali.fr/forfaits_ls/
Offres soumises à conditions.





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