On Fri, 19 Dec 2008 19:13:17 +0530 "Harinandan S" <harinandans@xxxxxxxxx> wrote: >Hi All, > >I'm using Gtk 2.12.2 over DirectFB 1.3.0. I want to set keyboard focus to a >window. In my application there are more than one window open at a time. I >dont have a mouse but just a keyboard. Unless mouse pointer moves over >another window the old window will still be in focus. How to set keyboard >focus to a window? > >Regards, >Harinandan S There are some options to try, but some may need to be run in an expose event callback gtk_widget_grab_focus(widget) gtk_window_set_focus (window, NULL); ??? YMMV, and I'm still learning myself. :-) I found that searching thru the maillist archives has many of these questions answered already....you can download the tarballs of each month and search for previous solutions. This will keep focus on the first window, but it's kind of an "negative soluion" by denying focus to other windows. #include <gtk/gtk.h> void destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *window1; GtkWidget *button; GtkWidget *button1; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK(destroy), 1); gtk_container_set_border_width(GTK_CONTAINER (window), 10); button = gtk_button_new_with_label ("Some Button"); gtk_container_add(GTK_CONTAINER(window), button); gtk_widget_show(button); gtk_widget_show (window); window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER (window1), 10); button1 = gtk_button_new_with_label ("Another Button"); gtk_container_add(GTK_CONTAINER(window1), button1); gtk_widget_show(button1); gtk_widget_show (window1); /* comment out this line and window1 gets automatic focus */ gtk_window_set_accept_focus(GTK_WINDOW(window1), FALSE); gtk_main (); return 0; } zentara -- I'm not really a human, but I play one on earth. http://zentara.net/Remember_How_Lucky_You_Are.html _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list