Re: Holding Down a Button
| From: | Scott Mattocks | Date: | Fri, 03 Dec 2004 13:04:31 +0000 |
| Subject: | Re: Holding Down a Button | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5297@lists.php.net to get a copy of this message | ||
Christian Weiske wrote:
You could start a timeout which calls the incValue as long the button is clicked. There is no way to get the event again and again - there is just one button press.That's what I ended up doing. I also had to connect the released signal to stop things when the user let go of the button. Just in case someone else needs to do this later, it ended up looking like this: <code> $this->connect_object('pressed', array(&$this, 'incValue'), 5); $this->connect_object('released', array(&$this, 'stopValue')); // The delay makes sure that they are holding the button before it // starts incrementing at the desired speed. If the delay is too small // clicking will be recognized as a quick press and hold. $this->delay = 200; ... function incValue($value) {
$this->value += $value;
$this->pressing = gtk::timeout_add($this->delay, array(&$this, 'incValue'), $value);
$this->delay = 100;
}
funciton stopValue()
{
if ($this->pressing) {
gtk::timeout_remove($this->pressing);
}
$this->delay = 200;
}
</code>
Thanks for you help.
--
Scott Mattocks
scott@crisscott.com
http://www.crisscott.com
http://pear.php.net/user/scottmattocks