Method

GtkWidgetgrab_focus

Declaration [src]

void
gtk_widget_grab_focus (
  GtkWidget* widget
)

Description [src]

Causes widget to have the keyboard focus for the GtkWindow it’s inside. widget must be a focusable widget, such as a GtkEntry; something like GtkFrame won’t work.

More precisely, it must have the GTK_CAN_FOCUS flag set. Use gtk_widget_set_can_focus() to modify that flag.

The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.