connect() and connect_object() question
| From: | Michael Waples | Date: | Wed, 06 Mar 2002 08:49:19 +0000 |
| Subject: | connect() and connect_object() question | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-1441@lists.php.net to get a copy of this message | ||
Im using in a script -
$menuitem1->connect_object('button-release-event', 'radiomenu_activate', 1);
I thought this shouldn't work as connect_object() required an object for the
argument but it's the only way I could get the script to get the $number
variable correctly.
I thought just using connect() was the right way as I'm not using any other
object in the function.
I'm just wondering what I'm missing. Is there something different about
'button-release-event'. ?
Here's the script
<?php
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
function delete_Event()
{
return false;
}
function shutdown()
{
print("Shutting down...\n");
gtk::main_quit();
}
function radiomenu_activate($menuitem, $number) {
echo "radio menu $number is checked\n\n";
}
$window = &new GtkWindow();
$window->connect("destroy", "shutdown");
$vbox = &new GtkVBox();
$window->add($vbox);
$menu = &new GtkMenu;
$menuitem1 = &new GtkRadioMenuItem(null, "Menu item 1");
$menuitem2 = &new GtkRadioMenuItem($menuitem1, "Menu item 2");
$menuitem1->connect_object('button-release-event', 'radiomenu_activate', 1);
$menuitem2->connect_object('button-release-event', 'radiomenu_activate', 2);
$menu->append($menuitem1);
$menu->append($menuitem2);
$menubar = &new GtkMenuBar();
$filemenu_label = &new GtkMenuItem("Menu");
$filemenu_label->set_submenu($menu);
$menubar->append($filemenu_label);
$vbox->pack_start($menubar);
$window->show_all();
echo $testing;
gtk::main();
?>