Re: Gtk3::Gdk::EventKey mappings



Thanks :) That pointed me in the right direction.

Dan

On Tue, Mar 3, 2015 at 7:14 PM, Terence Ferraro <terencejferraro gmail com> wrote:
I previously used the global snooper in Gtk2, but due to removed functionality, I added some code myself into Gtk3.pm to essentially provide the same functionality.

It looks like I locally define near the beginning of Gtk3.pm:

my $key_snooper_subroutine;

With a subroutine further below:

sub Gtk3::key_snooper_install
{
my ($gtk,$sub) = @_;
$key_snooper_subroutine = $sub;
}

Then I call in the application initialization directly: Gtk3->key_snooper_install(\&key_hook);

I've also got a modified Gtk3::Window::new function that includes:
if(defined($key_snooper_subroutine)) { $window->signal_connect(key_press_event => $key_snooper_subroutine); }

Among other things that are processed within the sub, I also save the last key data, for processing of delayed or redirected events, etc:

sub key_hook
{
my ($widget,$event,$data) = @_;
# ...stuff... $main::global_last_key_state = $state; $main::global_last_key_keyval = $event->keyval; $main::global_last_key_type = $event->type; }

In any case, one of the things I think you're looking for is the state mask, e.g. I check for: if($state =~ /shift-mask/) { ... }

And I think your L key should just be: Gtk3::Gdk::KEY_L or Gtk3::Gdk::KEY_l

Here's a snippet I use to ensure a given field can only accept numbers and decimals:

if($event->keyval != Gtk3::Gdk::KEY_BackSpace && $event->keyval != Gtk3::Gdk::KEY_0 && $event->keyval != Gtk3::Gdk::KEY_1 && $event->keyval != Gtk3::Gdk::KEY_2 && $event->keyval != Gtk3::Gdk::KEY_3 && $event->keyval != Gtk3::Gdk::KEY_4 && $event->keyval != Gtk3::Gdk::KEY_5 && $event->keyval != Gtk3::Gdk::KEY_6 && $event->keyval != Gtk3::Gdk::KEY_7 && $event->keyval != Gtk3::Gdk::KEY_8 && $event->keyval != Gtk3::Gdk::KEY_9 && $event->keyval != Gtk3::Gdk::KEY_Tab && $event->keyval != Gtk3::Gdk::KEY_Left && $event->keyval != Gtk3::Gdk::KEY_Right && $event->keyval != Gtk3::Gdk::KEY_period && $event->keyval != Gtk3::Gdk::KEY_KP_0 && $event->keyval != Gtk3::Gdk::KEY_KP_1 && $event->keyval != Gtk3::Gdk::KEY_KP_2 && $event->keyval != Gtk3::Gdk::KEY_KP_3 && $event->keyval != Gtk3::Gdk::KEY_KP_4 && $event->keyval != Gtk3::Gdk::KEY_KP_5 && $event->keyval != Gtk3::Gdk::KEY_KP_6 && $event->keyval != Gtk3::Gdk::KEY_KP_7 && $event->keyval != Gtk3::Gdk::KEY_KP_8 && $event->keyval != Gtk3::Gdk::KEY_KP_9) { return(1); }

Hope this helps!

Terence J. Ferraro

On Tue, Mar 3, 2015 at 2:54 AM, Daniel Kasak <d j kasak dk gmail com> wrote:
Greetings.

I'm trying to capture key press events like 'CTRL L'. I've found I can connect to the key-press-event of each window, and that method receives the window that intercepted the keypress, and a Gtk3::Gdk::EventKey. Where do I decode this? Data::Dumper says it's:

$VAR1 = bless( do{\(my $o = 82035488)}, 'Gtk3::Gdk::EventKey' );

Is there a nice mapping document or something? Or do I just use these constants, eg 82035488?

Thanks :)

Dan



_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]