gtk_window_propagate_key_event



Hi all,

I've just stumbled across a problem that seems to be solved by exactly
this stackoverflow answer:

https://stackoverflow.com/questions/61388055/gtk3-how-to-propagate-key-events-accelerators-shortcuts-from-local-to-global

In trying to transliterate the answer from c to Perl:

g_signal_connect(window,"key-press-event",G_CALLBACK(gtk_window_propagate_key_event),NULL);
g_signal_connect(window,"key-release-event",G_CALLBACK(gtk_window_propagate_key_event),NULL);

The following doesn't work, as the $window and $event data isn't passed on:

    $window->signal_connect(
      "key-press-event" => Gtk3::Window::propagate_key_event);
    $window->signal_connect(
      "key-release-event" => Gtk3::Window::propagate_key_event);

The following does, but seems very verbose:

    $window->signal_connect(
        "key-press-event" => sub {
            my ( $widget, $event ) = @_;
            $widget->propagate_key_event($event);
        }
    );
    $window->signal_connect(
        "key-release-event" => sub {
            my ( $widget, $event ) = @_;
            $widget->propagate_key_event($event);
        }
    );

Is there a better way?

Regards

Jeff

Attachment: signature.asc
Description: OpenPGP digital signature



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