Why doesn't this work? Driving me crazzzzzy
| From: | Jake Gordon | Date: | Wed, 06 Jul 2005 17:25:31 +0000 |
| Subject: | Why doesn't this work? Driving me crazzzzzy | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-5911@lists.php.net to get a copy of this message | ||
I've never really used much OO programming before, so I expect the answer to this is really easy, but I've lost most my hair now having been trying to figure out where the hell I'm going wrong for the last 3 hours.
The code is meant to change the contents of a part of the layout by destroying the object $main if it already exists, and then creating a new object with the same name and putting it in the same place.
I call it using:
$button->connect('clicked', 'change_main', $section);
The function is:
function change_main($button, $section, $main) {
global $layout, $main;
// First destroy what was here before, if anything
if($main) $main->destroy();
$main = &new GtkLabel($section);
$layout->put($main,100,40);
$main->show();
}
If I call the function like this instead:
$main = change_main(null, "splash", $main);
... with 'return $main' at the bottom of the function, it works. But how can I do this without returning $main seeing as ->connect doesn't allow this, no?
I don't know where to look for an answer. I don't know where to begin. Its driving me insane!
The problem is that $main doesn't exist within the function. Even though I've declared it as global in scope. Is this becuase you can't make an object global? So then how the hell can I do it????
HELP!!!!!!!!!!!!!!!!!!!!
Jake.