Re: another class question/problem
| From: | Rich Payne | Date: | Mon, 05 Mar 2001 23:56:18 +0000 |
| Subject: | Re: another class question/problem | ||
| References: | 1 | Groups: | php.gtk |
| Request: | Send a blank email to php-gtk+get-360@lists.php.net to get a copy of this message | ||
So I thought I understood this....but it seems I don't. If I use the same
code to return a GtkEntry, then do a get_text() on the return value I get:
Call to undefined function: get_text() in <b>main.php</b> on line
<b>48</b><br>
The offending lines:
<47> $te=$add_sys_window->get_text_entry();
<48> $temp=$te->get_text();
In the other class it's created like this:
$this->$name_entry = &new GtkEntry();
$table->attach($this->$name_entry,2,3,1,2);
$this->$name_entry->set_text("Test Message");
}
function get_text_entry() {
return $this->$name_entry;
}
just like the button version...and that works great.
I'm confused!
thanks for all the help,
--rdp
> On Mon, 5 Mar 2001, Frank M. Kromann wrote:
>
> > I think it is your use of variables in the class.
> >
> > Try this code:
> >
> > class Add_Window extends GtkWindow {
> > var $add_button;
> >
> > function Add_Window() {
> > $this->add_button = &new GtkButton("Add To DB");
> > }
> > function get_add_button() {
> > return $this->add_button;
> > }
> > }
> >
> >
> > - Frank
> > >
> > > I've run into another problem, and can't figure out what I'm doing
> > > wrong. I've created a class that extends GtkWindow, code looks like this
> > > (some of the GUI code has been removed for simplicity):
> > >
> > > class Add_Window extends GtkWindow {
> > > var $add_button;
> > >
> > > function Add_Window() {
> > > $add_button = &new GtkButton("Add To DB");
> > > }
> > > function get_add_button() {
> > > global $add_button;
> > > return $add_button;
> > > }
> > > }
> > >
> > > Now, from another php file I create an instance of this class, then try to
> > > register and event handler for the button, something like:
> > >
> > > $add_sys_window = &new Add_Window();
> > > $add_sys_window_add_button=$add_sys_window->get_add_button();
> > > $add_sys_window_add_button->connect('clicked',add_to_db);
> > >
> > > however, what happens is that I get one event when the window is created,
> > > and nothing else...I can click on that button all day and no events seem
> > > to get deliverd to the calling code.
> > >
> > > Any ideas? I'm pretty sure I used to do similar things in Java a while
> > > back w/o any trouble.
> > >
> > > TIA,
> > > --rdp
> > >
> > > --
> > > Rich Payne
> > > rpayne@alphalinux.org www.alphalinux.org
> > >
> > >
> > > --
> > > PHP GTK Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-gtk-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-gtk-help@lists.php.net
> > > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> > >
> > >
> > >
> >
> >
> >
> >
> >
>
>
--
Rich Payne
rpayne@alphalinux.org www.alphalinux.org