PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Self destruction class (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Self destruction class
#1190
bolzer (User)
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Self destruction class 1 Month, 2 Weeks ago Karma: 0  
Hi!

I´d like to build a class which does something and returns a user input, not an object.

The class extends the GtkDialog Class, which will be contructed at first. After the user clicks "OK" the dialog shall be destructed and a result returned (from a GtkEntry inside the dialog).

Example:

Code:
class x extrends GtkDialog{
function __contruct(){
//contains dialog attributes, GtkEntry etc
}
function destruct(){
//will be called on dialog ok
//reads entry value
//here the class shall be destructed and a return value transmitted
}
}

$return = new x();
Everything is working fine but i alway get a object back. I can acess the value with $return->value, and destroy it later using unset($return). but i would prefer a solution descibed above- if possibel.
 
  The administrator has disabled public write access.
#1193
kksou (Admin)
Admin
Posts: 443
graph
User Online Now Click here to see the profile of this user
Re:Self destruction class 1 Month, 2 Weeks ago Karma: 8  
Hi,

PHP5's OOP is not as full-fledged as that of C++.

In any case, there's no way you can return a value in the constructor method. So when you do a new class() in PHP5, it will always return a pointer to a new instance of the class.

For you case, you will need at least 2 lines: the first one to create an instance of the dialog class, and the second to retrieve the user input from GtkEntry. If you want, you may add a third to destroy the object.

Regards,
/kksou
 
  The administrator has disabled public write access.
#1196
bolzer (User)
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Re:Self destruction class 1 Month, 2 Weeks ago Karma: 0  
Ok, i did not really belived there is a other solution as i did not found anything like this on the web.
Thanks anyway, i´m using the "3 lines solution" already :-)

I´m working on a gtk project since 3 month, and i want to mention that this here is the best php-gtk related site on the web. Thanks and good job kksou!

Cheers
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved