I'm trying to intercept keypresses like "g" or "CTRL P", or whatever.

The following test scripts works fine under Gtk2, but under Gtk3, I get this error message:

*** Gtk3::Gdk::keyval_name: passed too many parameters (expected 1, go +t 2); ignoring excess at keyval.pl line 22. Argument "Gtk3::Gdk" isn't numeric in subroutine entry at /usr/lib/x86_64-linux-gnu/perl5/5.26/Glib/Object/Introspection.pm +line 67 (#1)

I checked the docs (at https://developer.gnome.org/); I can't see any difference between Gtk2 and Gtk3 versions of the ->keyval function.

Any ideas, oh infinitely wise ones?

#!/usr/bin/perl use strict; use diagnostics; use warnings; use Gtk3 '-init'; my $window = Gtk3::Window->new('toplevel'); $window->set_title('Hello world'); $window->set_position('center'); $window->set_default_size(500, 500); $window->signal_connect('delete-event' => sub { Gtk3->main_quit(); exit; }); $window->signal_connect('key-press-event' => sub { my ($widget, $event) = @_; print "keyval " . Gtk3::Gdk->keyval_name($event->keyval) . "\n"; }); $window->show_all(); Gtk3->main();

In reply to Use Gtk3::Gdk to intercept keypresses by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.