Re: Connecting data
| From: | Scott Mattocks | Date: | Fri, 03 Dec 2004 13:47:50 +0000 |
| Subject: | Re: Connecting data | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5300@lists.php.net to get a copy of this message | ||
Tom Rogers wrote:
PHP GTK seems to do strange things with events and classes.This only because PHP-Gtk uses PHP4. Objects are still copied instead of passed by reference. When PHP-Gtk2 is ready you shouldn't see these problems as much (at all).
The way I avoid this is to store class variables in the gtk object with $gtk_object->set_data() and $gtk_object->get_data()I think its cleaner to use members of you class rather than have one widget hold info for the whole class. Why tie the value to the widget if it's really part of the class? ... $this->adjustment->connect('value_changed', array(&$this, 'changeValue')); function changeValue(&$adjustment) {
$this->value = $adjustment->value;
// Instead of...
// $this->button->set_data('counter', $adjustment->value);
}
$this->button->connect_object('button-press-event', array(&$this, 'incValue'));
function incValue()
{
$this->value += $this->value;} ... -- Scott Mattocks scott@crisscott.com http://www.crisscott.com http://pear.php.net/user/scottmattocks