Re: GtkTextView, g_signal_connect_after and button_press_event



Hi,

On Thu, 2002-08-08 at 11:12, Unai wrote:
> Hi.
> 
> How can I use the g_signal_connect_after for the button_press_event on 
> the GtkTextView? It seems that the TextView is handling the event and 
> my callback isn't called by the left mouse button. (the right mouse 
> button works ok).
> 
> Here is the example code that shows it. The left mouse button doesn't 
> call my callback.
> 
> #include <gtk/gtk.h>
> 
> void on_view_button_press_event (GtkWidget *widget, gpointer data);
> 
> int main (int argc, char *argv[])
> {
> 	GtkWidget *window, *view;	
> 	GtkTextBuffer *buffer;	
> 
> 	gtk_init(&argc, &argv);		
> 	window =gtk_window_new(GTK_WINDOW_TOPLEVEL);	
> 	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);

Use g_signal_connect instead, and return FALSE if you didn't handle the
event, so that the GtkTextView can continue processing.  Also, keep in
mind that the correct callback prototype is:

gboolean callback (GtkWidget *widget, 
		   GdkEventButton *event, 
		   gpointer data);

Regards,
Gustavo

> 	gtk_container_add(GTK_CONTAINER(window), view);	
> 	gtk_widget_show(view);	
> 	gtk_widget_show(window);	
> 	
> 	gtk_main();	
> 	return 0;
> }
> 
> void on_view_button_press_event (GtkWidget *widget, gpointer data) 
> {
> 	gtk_main_quit();
> }
> 
> Thanks for your help
> 
>        Unai
> 
> http://david.es.gnome.org
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 
> 





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