On Mon, Jul 17, 2006 at 07:46:31PM +0530, [EMAIL PROTECTED] wrote: > I am trying to register a callback for "backspace" signal on entry > widgets like below, > > g_signal_connect (G_OBJECT (entry), "backspace", > G_CALLBACK (enter_callback),NULL); > > and inside the callback I am just printing a message as below, > > static void enter_callback( GtkWidget *widget,gpointer data); > { > printf ("backspace event received\n"); > } > > But when I press backspace key on the text in the editor, > last character is getting deleted instead of executing my function.
Instead? Your function should be called in addition to the deletion of the character before cursor. To hijack backspace for a particular widget you have to prevent the default handler from running, see the attached example. To do that for many widgets, subclass GtkEntry and override its backspace() method. In any case I doubt changing backspace behaviour is something your users will thank you for. Yeti -- Anonyms eat their boogers. ============================================================================= #include <gtk/gtk.h> static void backspace(GtkEntry *entry, gpointer userdata) { g_print("backspace(%p)\n", entry); g_signal_stop_emission(entry, GPOINTER_TO_UINT(userdata), 0); } int main(int argc, char *argv[]) { GtkWidget *window, *entry; guint signal_id; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(window), entry); signal_id = g_signal_lookup("backspace", G_TYPE_FROM_INSTANCE(entry)); g_signal_connect(entry, "backspace", G_CALLBACK(backspace), GUINT_TO_POINTER(signal_id)); gtk_widget_show_all(window); gtk_main(); return 0; } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list