diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 994a1500f0..6c34734865 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -1196,6 +1196,7 @@ gtk_entry_get_input_purpose GtkInputHints gtk_entry_set_input_hints gtk_entry_get_input_hints +gtk_entry_grab_focus_without_selecting GTK_ENTRY diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 4be143c5ea..73d0a821c4 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -5016,6 +5016,28 @@ gtk_entry_grab_focus (GtkWidget *widget) } } +/** + * gtk_entry_grab_focus_without_selecting: + * @entry: a #GtkEntry + * + * Causes @entry to have keyboard focus. + * + * It behaves like gtk_widget_grab_focus(), + * except that it doesn't select the contents of the entry. + * You only want to call this on some special entries + * which the user usually doesn't want to replace all text in, + * such as search-as-you-type entries. + * + * Since: 3.16 + */ +void +gtk_entry_grab_focus_without_selecting (GtkEntry *entry) +{ + g_return_if_fail (GTK_IS_ENTRY (entry)); + + _gtk_entry_grab_focus (entry, FALSE); +} + static void gtk_entry_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir) diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h index ce3c021eca..57d65a5756 100644 --- a/gtk/gtkentry.h +++ b/gtk/gtkentry.h @@ -374,6 +374,9 @@ void gtk_entry_set_tabs (GtkEntry GDK_AVAILABLE_IN_3_10 PangoTabArray *gtk_entry_get_tabs (GtkEntry *entry); +GDK_AVAILABLE_IN_3_16 +void gtk_entry_grab_focus_without_selecting (GtkEntry *entry); + G_END_DECLS #endif /* __GTK_ENTRY_H__ */