Hello, Anybody has idea how to emit in GTK (2.11.6) some keypress event into main event loop?
I have mouse clickable button and want to send to my text_view a keyboard press. I'm doing this way: in main code: g_signal_connect(G_OBJECT(my_button), "button-press-event", G_CALLBACK(press_callback), G_OBJECT(textview)); in callback: static void press_callback( GtkWidget *widget, GdkEventButton *e, GtkWidget *text_view ) { g_print("button press\n"); GdkEvent *event; event = gdk_event_new(GDK_KEY_PRESS); event->key.keyval = GDK_K; event->key.window = gtk_text_view_get_window(text_view, GTK_TEXT_WINDOW_TEXT); event->key.time = 0; gtk_main_do_event(&event); } I get nothing in my text_view view but have the following debug output: GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GdkWindow' gtktextview.c:4303: focus_out_event >Lines Validated (gtktextview.c:3492) visible rect: 0,0 226 x 107 invalidated rect: 0,0 226 x 28 >Exposed (gtktextview.c:4447) or if trying another approach with sending event directly to text_view widget: static void press_callback( GtkWidget *widget, GdkEventButton *e, GtkWidget *text_view ) { g_print("button press\n"); GdkEvent *event; event = gdk_event_new(GDK_KEY_PRESS); event->key.keyval = GDK_K; event->key.window = gtk_text_view_get_window(text_view, GTK_TEXT_WINDOW_TEXT); event->key.time = 0; g_signal_emit_by_name(GTK_TEXT_VIEW(text_view), "key_press_event", event); } the program seems go in correct way, but I get segmentation fault: >Invalidate, onscreen_validated = 1 now FALSE (gtktextview.c:3442) gtktextview.c:3454: adding first validate idle 13 gtktextview.c:3461: adding incremental validate idle 14 gtktextview.c:1812 Invalidating due to layout invalidate signal >Invalidate, onscreen_validated = 0 now FALSE (gtktextview.c:3442) Invalidating due to layout invalidate signal >Invalidate, onscreen_validated = 0 now FALSE (gtktextview.c:3442) TEXTVIEW: K -- callback of "changed" signal for TextView gtktextview.c:7131: scrolling onscreen gtktextview.c:1812 gtktextview.c:3410 removing first validate in gtktextview.c:3367 >Updating layout width (gtktextview.c:1965) Segmentation fault Please suggest correct mailing list if I'm posting on the wrong one. Thanks! Best regards, Ivan _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list