Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select text in GtkEntry

Tags:

c

gtk

gtkentry

i have dialog window with GtkEntry. I want to select all text in entry right after dialog window becomes visible to user. I tried this, but its not working, i see no selection:

static void OnEntryShow(GtkWidget *entry, gpointer user_data)
{
     gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
}
...
gtk_entry_set_text(GTK_ENTRY(myEntry), "text");
g_signal_connect(myEntry, "show", G_CALLBACK(OnEntryShow), NULL);
if (gtk_dialog_run(GTK_DIALOG(myDialog)) == GTK_RESPONSE_OK)
...

How can i select text in GtkEntry after GtkDialog becomes visible?

like image 363
BPS Avatar asked Apr 26 '12 16:04

BPS


1 Answers

Perhaps you want the GtkEntry to grab focus?

Try this:

gtk_widget_grab_focus (entry);

where entry is in this case the pointer to your GtkEntry widget.

The documentation of the function can be found here.

like image 65
PALEN Avatar answered Sep 22 '22 04:09

PALEN