note 151 added to gtk.gtkwidget.method.add_accelerator.php
| From: | dick at noiz dot nl | Date: | Thu, 13 Jun 2002 18:18:28 +0000 |
| Subject: | note 151 added to gtk.gtkwidget.method.add_accelerator.php | ||
| Groups: | php.gtk.webmaster | ||
| Request: | Send a blank email to php-gtk-webmaster+get-491@lists.php.net to get a copy of this message | ||
Usage example:
#!/usr/bin/php -q
<?php
if (!extension_loaded('gtk')){ dl( 'php_gtk.' . (strstr( PHP_OS,
'WIN') ? 'dll' : 'so')); }
// create the main window
$window = new GtkWindow(GTK_WINDOW_DIALOG);
$window->set_title('Accelerator Example');
$window->connect_object('destroy', array('gtk', 'main_quit'));
$window->connect_object('delete-event', array('gtk', 'main_quit'));
// create an accelerator group and add it to this window
$accelgroup = &new GtkAccelGroup();
$window->add_accel_group($accelgroup);
// add a VBox
$box1 = &new GtkVBox();
$window->add($box1);
// create a toolbar and add it to the Vbox
$toolbar = &new GtkToolbar(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_TEXT);
$box1->pack_start($toolbar, FALSE, TRUE, 0);
// create the Exit button and add it to the toolbar
$exit_button = &new GtkButton("");
$label = $exit_button->child;
$exit_button_key = $label->parse_uline("E_xit");
$exit_button->add_accelerator("clicked", $accelgroup, $exit_button_key, GDK_MOD1_MASK,
0);
$exit_button->connect_object('clicked', array('gtk', 'main_quit'));
$toolbar->add($exit_button);
$window->show_all();
Gtk::main();
?>
http://gtk.php.net/manual/en/gtk.gtkwidget.method.add_accelerator.php