Reputation: 638
I'm creating a popup gtkdialogbox that prompts the user for input. Here's my code:
GtkWidget *button = gtk_button_new_with_label ("add a new button");
//adding a new button
GtkWidget * new_button_dialog = gtk_dialog_new_with_buttons("new button",(GtkWindow *)container,GTK_DIALOG_DESTROY_WITH_PARENT,"OK", GTK_RESPONSE_NONE,NULL);
GtkWidget * content_area = gtk_dialog_get_content_area (GTK_DIALOG (new_button_dialog));
GtkWidget * button_name_label = gtk_label_new ("Press escape at any time to cancel.\ntype in the button name");
gtk_container_add (GTK_CONTAINER (content_area) , button_name_label);
GtkWidget * button_name_entry = gtk_entry_new();
gtk_entry_set_activates_default((GtkEntry*)button_name_entry,TRUE);
gtk_container_add(GTK_CONTAINER(content_area), button_name_entry);
problem is I'm tryign to accept the input when the user presses enter gtk_entry_set_activates_default when I press enter(when the entry has focus) I get nothing
thanks
Upvotes: 0
Views: 149
Reputation: 638
here's my working code:
GtkWidget * ok_button = gtk_dialog_get_widget_for_response(new_button_dialog, GTK_RESPONSE_OK);
gtk_entry_set_activates_default((GtkEntry*)button_name_entry,TRUE);
gtk_widget_grab_default(ok_button);
Upvotes: 1