bool activate_default();

Activates the window's default widget (e.g. sends the "activate" signal to the widget). Returns true if the widget could be activated, false if not.

Before you can activate the default widget, you need to define it with set_default() .

That is very useful if you don't know which widget the default one is (or don't care about that), but need to cause it to be clicked/activated. The example shows how this method is used to cause the default button to be activated when the user presses the Return key on the text entry widget.

Example 157. Activating the button with return key on entry

//Create the widgets
$wnd   = new GtkWindow();
$vbox  = new GtkVBox();
$entry = new GtkEntry();
$btn   = new GtkButton('Button');

//add them to the box

//add the box to the window

//little echo method
function echoit($value) { echo $value . "\r\n"; }

//connect the clicked signal to out echo method
$btn->connect_simple('clicked', 'echoit', $btn->get_label());
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));

//here we let the activate signal of the gtkentry call the
//activate_default method of the window
$entry->connect_simple('activate', array($wnd, 'activate_default'));

//allow our button to be the default widget

//set the button the default one in the window


See also: set_default()