Problem with GtkTextView and the button_press_event.



Hi!

I'm having a problem with a GtkTextView and the button_press_event 
callback. Below is the example code that shows it. The problem is that 
if I use g_signal_connect_after, the callback is not called when I 
click on the TextView with the left mouse button, but it's called 
correctly if I click with the right mouse button. If I use 
g_signal_connect  (without the "after"), both buttons work correctly. 

Any clue about why does this happen?

#include <gtk/gtk.h>
void on_view_button_press_event (GtkWidget *widget, gpointer data);
void destroy (GtkWidget *widget, gpointer data);

int main (int argc, char *argv[])
{
        GtkWidget *window, *view, *scrolledwindow;      
        GtkTextBuffer *buffer;  

        gtk_init(&argc, &argv);         
        window =gtk_window_new(GTK_WINDOW_TOPLEVEL);    
        g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK(destroy), 
NULL);  
        buffer = gtk_text_buffer_new(NULL);             
        view = gtk_text_view_new_with_buffer (buffer);  
        g_signal_connect_after (G_OBJECT(view), "button_press_event", 
G_CALLBACK(on_view_button_press_event), NULL);          
        scrolledwindow = gtk_scrolled_window_new(NULL, NULL);   
        gtk_container_add(GTK_CONTAINER(scrolledwindow), view); 
        gtk_container_add(GTK_CONTAINER(window), scrolledwindow);       
        gtk_widget_show(view);  
        gtk_widget_show(scrolledwindow);        
        gtk_widget_show(window);        
        
        gtk_main();     
        return 0;
}

void on_view_button_press_event (GtkWidget *widget, gpointer data) 
{
        gtk_main_quit();
}
void destroy (GtkWidget *widget, gpointer data) 
{
        gtk_main_quit ();
}

Thanks for the help

        Unai

http://david.es.gnome.org



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