Re: How to set keyboard focus to a window?
- From: "Harinandan S" <harinandans gmail com>
- To: gtk-list gnome org
- Subject: Re: How to set keyboard focus to a window?
- Date: Mon, 22 Dec 2008 10:54:26 +0530
Both the APIs set the focus to a widget if the mouse pointer is over the window containing the widget. Hovewer in my case mouse is not there and hence focus is not going to that window. Is there any other way to get the focus?
gtk_window_set_focus (window, widget);
On Fri, Dec 19, 2008 at 8:11 PM, zentara <zentara1 sbcglobal net>
There are some options to try, but some may need to be run in an expose event callback
On Fri, 19 Dec 2008 19:13:17 +0530
"Harinandan S" <harinandans gmail com
>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?
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
This will keep focus on the first window, but it's kind of an "negative soluion"
by denying focus to other windows.
void destroy(GtkWidget *widget, gpointer data)
int main(int argc, char *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");
window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER (window1), 10);
button1 = gtk_button_new_with_label ("Another Button");
/* comment out this line and window1 gets automatic focus */
I'm not really a human, but I play one on earth.
gtk-list mailing list
gtk-list gnome org
] [Thread Prev