Re: [PHP-GTK] Re: Key Press php-gtk1
[email protected] (Brian Stumm) Fri, 19 Feb 2010 06:53:15 -0800
| Newsgroups | php.gtk.general |
|---|---|
| Message-ID | <[email protected]> |
Jake, I already thought of that, unfortunately if one shift is already depressed nothing happens when you press the other. At least in php-gtk version 1. On Fri, Feb 19, 2010 at 6:48 AM, Jake <[email protected]> wrote: > If one Shift key is already down and you press the other, does this trigger > another key-press event? If so, can't you detect both are down by > incrementing/decrementing a counter when you get a key press/release for > Shift and checking for the counter being 2? > > -Jake > > On Mon, Feb 15, 2010 at 5:44 PM, Brian Stumm > <[email protected]> wrote: >> >> Thanks to Madeleine for pointing out my error, I can now detect key >> release as well as key press. But I now have a new problem and looking >> for any ideas anyone might have. >> >> I must choose two keys on the keyboard that cannot be pressed using >> only one hand. Most keys fall into the "auto repeat" category where >> while holding the key down for long periods it will repeat the "press" >> action. I'm sure you've all experienced the annoying beeping from a >> computer with a key that is stuck down for whatever reason. I decided >> I could use the two shift keys as my two handed solution, however both >> shift keys use the value 65505 and I cannot determine that both shift >> keys are depressed. Using a combination of ctrl and shift is out >> because you can press them both using only one hand. >> >> Is there a way to treat the two shift or ctrl keys separate? Is there >> a way to disable auto-repeat for the keyboard (temporarily) via >> php-gtk? Any other ideas? >> >> Thanks. >> >> On Mon, Feb 15, 2010 at 12:50 PM, Madeleine D. <[email protected]> wrote: >> > >> > Brian - >> > >> > You need to add 'add-events', after the realize, as in: >> > >> > $alert_window->add_events(GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK); >> > >> > >> > The key press mask is probably not needed, but I always add it anyway. >> > >> > >> > Madeleine D. >> > >> > >> > >> > >> > >> > Brian Stumm wrote: >> >> >> >> Not sure if messages are going through or not but... >> >> >> >> I've discovered the key-press-event and key-release-event and while >> >> key-press is working for me, the key-release does not seem to work. >> >> >> >> Here is a snippet from my code: >> >> >> >> $alert_window = &new GtkWindow(GTK_WINDOW_DIALOG); >> >> $alert_window->connect('delete-event', 'hide_window'); >> >> $alert_window->set_border_width(0); >> >> $alert_window->set_policy(0, 0, 0); >> >> $alert_window->set_title('Notice!'); >> >> $alert_window->set_name('AlertWindow'); >> >> $alert_window->set_usize(400,430); >> >> $alert_window->realize(); >> >> $alert_window->set_position(GTK_WIN_POS_CENTER); >> >> $alert_window->connect('key-press-event', 'onKeyPress'); >> >> $alert_window->connect('key-release-event', 'onKeyRelease'); >> >> -----------------8<--SNIP >> >> >> >> /***** ONKEYPRESS/RELEASE() *****/ >> >> function onKeyPress($widget, $event) { >> >> global $righthand, $lefthand; >> >> echo "Pressed: " . $event->keyval; >> >> return true; >> >> } >> >> function onKeyRelease($widget, $event) { >> >> global $righthand, $lefthand; >> >> echo "Released: " . $event->keyval; >> >> return true; >> >> } >> >> >> >> Key Press echo's Pressed and a value (numeric) but the key release >> >> does nothing. Am I doing something wrong? >> >> >> >> >> >> On Mon, Feb 15, 2010 at 6:01 AM, Brian Stumm >> >> <[email protected]> wrote: >> >> >> >>> >> >>> First, I am still using php-gtk1. I'd like to make the move to v2 but >> >>> do not have the luxury right now. >> >>> >> >>> I am looking to detect when keys are pressed (and held down) in >> >>> php-gtk version 1. This is for a "two hand, no tie down" safety >> >>> feature on our machines. Access to our machines is made possible by >> >>> lifting the top of the machine using air cylinders. The air cylinders >> >>> are controlled via an electric valve. To lower the top I need to >> >>> require the user to press two keys on opposite sides of the keyboard >> >>> and keep them depressed until the top closes completely. If they >> >>> release before the top closes completely the top should go back up. >> >>> >> >>> Is there a way I can monitor key press and key release in version 1 of >> >>> php-gtk? >> >>> >> >>> -- >> >>> Brian Stumm >> >>> ETS Energy Technology Systems, Inc. >> >>> http://EnergyTechnologySystems.com >> >>> [email protected] >> >>> 509-276-2015 (PH) >> >>> 509-276-2016 (FX) >> >>> >> >>> >> >> >> >> >> >> >> >> >> > >> >> >> >> -- >> Brian Stumm >> ETS Energy Technology Systems, Inc. >> http://EnergyTechnologySystems.com >> [email protected] >> 509-276-2015 (PH) >> 509-276-2016 (FX) >> >> -- >> PHP-GTK General Mailing List (http://gtk.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- Brian Stumm ETS Energy Technology Systems, Inc. http://EnergyTechnologySystems.com [email protected] 509-276-2015 (PH) 509-276-2016 (FX)