Re: [gtk-list] signal/slot question



On Tue, 3 Mar 1998, Robert Wilhelm wrote:

> 
> 
> Doing a gtk_signal_connect(), the data (last argument) does not reach
> the callback function.
> 
> What I am doing wrong here?
> 
> Robert
> 
> #include <gtk/gtk.h>
> 
> static void  cb(GtkWidget* widget, gpointer data)
> {
>   printf("cb %p %p %p\n",widget,data, *(void **) data);
> }
> int main (int argc, char *argv[])
> {
>   GtkWidget *window;
> 
>   gtk_init (&argc, &argv);
>   
>   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> 
>   gtk_widget_set_events(window,  GDK_BUTTON_PRESS_MASK| GDK_BUTTON_RELEASE_MASK );
> 
>   gtk_signal_connect(GTK_OBJECT(window),"button_press_event",GTK_SIGNAL_FUNC(cb),window);
>   gtk_signal_connect(GTK_OBJECT(window),"button_release_event",GTK_SIGNAL_FUNC(cb),NULL);
					   ^^^^^^^^^^^^^^^^^^^^

the callback semantics for GtkWidget::*_event signals look as follows:

gint (* button_press_event)      (GtkWidget          *widget,
                                  GdkEventButton     *event,
                                  gponter             user_data)
{
  if (event->button==3)
  {
    printf("button 3 pressed\n");
    return TRUE;
  }
  
  /* here we return FALSE, since we didn't handle the event and leave it
     up to other widgets/gtk portions to perform further processing
  */
  
  return FALSE;
}
                                      					   
					   
> 
>   gtk_widget_show(window);
> 
>   gtk_main ();
>            
>   return 0;
> }
> 

---
ciaoTJ



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