Re: GtkImage mouse click signal





If I understand what you're looking for, I recently had the same question.

Here's what I've got, though it might not be the best way.

First, you have to put your image in an event box, so you can generate events when you click on it. Then you have to connect the event masks that you want to be notified about. The rest is like hooking up a button.


    myeventbox = gtk_event_box_new ();
    gtk_widget_show (myeventbox);
    gtk_container_add (GTK_CONTAINER (frame2), myeventbox);
    gtk_widget_add_events(myeventbox, GDK_BUTTON_RELEASE_MASK);
    gtk_widget_add_events(myeventbox, GDK_BUTTON_PRESS_MASK);
    gtk_widget_add_events(myeventbox, GDK_BUTTON1_MOTION_MASK);

    myimage = gtk_image_new_from_pixbuf(/*blah blah*/);
    gtk_widget_show (myimage);
    gtk_container_add (GTK_CONTAINER (myeventbox), myimage);


Hope that makes sense....
bc



On Sep 7, 2004, at 10:15 AM, Andy Grebe wrote:

What is the best way to generate a mouse click signal when dealing with
a GtkImage?  Right now the only way I have of doing this is by using
buttons.  Is there a way to do this if I place the image into a
GtkFixed?  Perhaps get an interrupt when clicking on the fixed, then
grabbing the location of the mouse?

If I missed something in the API or Tutorial, I'll gladly read it, if
you could reference the location.

Thanks


--
Andy Grebe


_______________________________________________
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]