PHP-GTK
Saturday, October 25, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkWindow Constructor
GtkWindow::activate_focusnext

Last updated: Sun, 12 May 2013
view this page in English

GtkWindow::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

<?php
//Create the widgets
$wnd   = new GtkWindow();
$vbox  = new GtkVBox();
$entry = new GtkEntry();
$btn   = new GtkButton('Button');
 
//add them to the box
$vbox->pack_start($entry);
$vbox->pack_start($btn);
 
//add the box to the window
$wnd->add($vbox);
 
//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
$btn->set_flags(Gtk::CAN_DEFAULT);
 
//set the button the default one in the window
$wnd->set_default($btn);
 
$wnd->show_all();
Gtk::main();
?>

See also: set_default()


User Contributed Notes
gtk.gtkwindow.method.activate_default.php
add a note about notes
There are no user contributed notes for this page.


previousGtkWindow Constructor
GtkWindow::activate_focusnext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:51:01 2013 CEST