RES: [PHP-GTK] PHP4 Object Issues.
| From: | Piero B. Contezini | Date: | Wed, 03 Aug 2005 12:08:57 +0000 |
| Subject: | RES: [PHP-GTK] PHP4 Object Issues. | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6136@lists.php.net to get a copy of this message | ||
Thanks, with your solution it Works as i dont need to use any stored
data in the object, but the problem itself resides and i would like to
know if it is a bug or a misundersting of the OOP in PHP
Piero
-----Mensagem original-----
De: Tom Rogers [mailto:trogers@kwikin.com]
Enviada em: terça-feira, 2 de agosto de 2005 19:59
Para: php-gtk-general@lists.php.net
Assunto: Re: [PHP-GTK] PHP4 Object Issues.
Hi,
Wednesday, August 3, 2005, 5:18:17 AM, you wrote:
PBC> I know it is not a question to be placed here, but with GTK we
really
PBC> use all the advanced procedures of PHP, in other places most people
dont
PBC> even know its possible to do.
PBC> The problem is:
PBC> I have a object variable that stores the current selected node of a
PBC> Ctree Object, whenever a user clicks on it, the node is stored.
PBC> Somewhere in the program, I need to add a new field, and i use the
node
PBC> as the parent node for the new one.
PBC> The problem i'm having is about crossing objects thru the execution
PBC> flow, and using a object variable from a function within this
object,
PBC> but being called from outside. The variable in question appear to
be
PBC> null, the code exemple shows my problem:
PBC> The Function atached to the select event:
PBC> function selecionar($node, $id) {
PBC> global $projeto;
$data = $this->>ctree->node_get_row_data($node);
PBC> $this->node_selecionado = $node; // this is the variable i
need
PBC> to store
PBC> }
PBC> The Function that uses this variable:
PBC> function add_toolbox($objeto) {
PBC> $objptr =
$this->>ctree->insert_node($this->node_selecionado,null,array("N",$objet
o
->>nome,$tipo),0,null,null,null,null,false,false);
$this->>ctree->node_set_row_data($objptr,array($this->objeto_pai,$objeto
)
PBC> );
PBC> }
PBC> Here, the variable is ALWAYS null, but when i print it from other
PBC> function it is ok, anyone had this problem before?
PBC> The function add_toolbox is called always from a main object, this
two
PBC> functions are from a object called toolbox, so they would be able
to
PBC> share this variable.
PBC> Thanks
PBC> Piero
PBC> Obs: Maybe php has context issues with objects?
What I do to overcome this is to store any data like that inside the
actual gtk widget with
$this->ctree->set_data('current_node',$node);
$node = $this->ctree->get_data('current_node');
Although $this suffers during event calls the widget data survives.
You could also use the window object that holds the ctree object, in
my case it is a GtkVBox.
--
regards,
Tom
--
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php