NAME
Gtk2::Ex::KeySnooper -- keyboard snooper as object
SYNOPSIS
use Gtk2::Ex::KeySnooper;
my $snooper = Gtk2::Ex::KeySnooper->new (\&myfunc, $mydata);
# disconnected when destroyed
$snooper = undef;
DESCRIPTION
A Gtk2::Ex::KeySnooper
object installs a given function as a key snooper in the Gtk main loop and when the KeySnooper object is destroyed it removes that function. The idea is that it can be easier to manage the lifespan of an object than to keep an integer ID safe somewhere and remember Gtk2->key_snooper_remove
at the right places.
FUNCTIONS
$ks = Gtk2::Ex::KeySnooper->new ($func)
$ks = Gtk2::Ex::KeySnooper->new ($func, $userdata)
-
Create and return a KeySnooper object calling the given
$func
. The calls made are perGtk2->key_snooper_install
, ie.$stop = &$func ($widget,$event,$userdata)
where
$func
should return true if it wants to stop event processing, ie. to consume the event, or false to let it propagate to other handlers, the same as akey-press-event
signal handler return. For examplemy $snooper = Gtk2::Ex::KeySnooper->new (\&myfunc, $mydata); sub myfunc { my ($widget, $event, $userdata) = @_; if ($event->type eq 'key-press') { if ($event->keyval == MY_DESIRED_KEYVAL) { do_something(); return 1; # don't propagate event further } } else { # key release ... } return 0; # propagate event }
$snooper->remove()
-
Remove the snooper function, if not already removed. This is done automatically when
$snooper
is destroyed, but you can do it explicitly sooner if desired.
SEE ALSO
Gtk2::Widget, Glib::Ex::WidgetBits, Glib::Ex::SignalIds
HOME PAGE
http://www.geocities.com/user42_kevin/gtk2-ex-widgetbits/index.html
LICENSE
Copyright 2008 Kevin Ryde
Gtk2-Ex-WidgetBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Gtk2-Ex-WidgetBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Gtk2-Ex-WidgetBits. If not, see http://www.gnu.org/licenses/.