elsenor
elsenor

Reputation: 90

widget not within a Gtk Window

I am working with trying to set a button as the default within a program so that as soon as data is entered within the entry boxes the user simply has to press enter to continue instead of dragging up the mouse or tabbing awkwardly.

My code for this is:

gtk_entry_set_activates_default(__w_passwdEntry, true);
gtk_entry_set_activates_default(__w_uNameEntry, true);
gtk_widget_set_can_default(GTK_WIDGET(__w_loginBtn), true);
gtk_widget_grab_default(GTK_WIDGET(__w_loginBtn));

and I get an error on the last line, the error reads:

(app_name:2345): Gtk-WARNING **: gtkwidget.c:6796: widget not within a GtkWindow

How do I go about associating the button with a window? That and how would I determine what the window I would need to associate the button with is?

I created the basics of the GUI in Glade and I am working on doing everything besides the layout in code.

Upvotes: 1

Views: 672

Answers (1)

elsenor
elsenor

Reputation: 90

Found an answer, used g_signal_connect linked to "activate":

g_signal_connect(__w_uNameEntry, "activate", G_CALLBACK(*credentialsCheck), NULL);
g_signal_connect(__w_passwdEntry, "activate", G_CALLBACK(*credentialsCheck), NULL);

Where credentialsCheck() is the function linked to the callback of the login button. So this is not a perfect solution but it works for now.

Upvotes: 1

Related Questions