How to prevent Gtkentry from getting focus automatically?

The GtkEntry will get focus when the application starts. How to avoid it?

Lacking some knowledge about focus , I can’t figure this out.

That should be solved by calling gtk_widget_set_receives_default (entry, FALSE)

This function does not solve the problem.

Is this api similar to autofocus?

Ah, indeed. default is about widget activatation when pressing Enter, not about focus.

I’d say you can either:

  • Call gtk_widget_grab_focus to focus another widget (a button, for example) or
  • Call gtk_root_set_focus(GTK_ROOT(window), NULL) if you want to have no focused widget.

Using gtk_root_set_focus(GTK_ROOT(window), widget); solved the problem

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.