dk / Prima

prima.eu.org
Other
106 stars 27 forks source link

Fix typo in unix/event.c: code for (keypad 9) #94

Closed HaraldJoerg closed 1 year ago

HaraldJoerg commented 1 year ago

This fix makes Prima report a release of keypad-9 under Unix. Here's a demo program:

use 5.020;

use Prima;
use Prima::Application name => 'Press and relelase "9" on your keypad';

my $main = Prima::MainWindow->create(
    text => $::application->name,
    menuItems => [
        ['~File' => [
            ['~Quit' => 'Ctrl+Q', '^Q',
             sub { $::application->close } ],
        ],
     ],
    ],
    onKeyDown => \&key_press,
    onKeyUp   => \&key_release,
);

sub key_press {
    my ($widget,$code,$key,$mod) = @_;
    say q(You pressed '), chr $code, q(');
}

sub key_release {
    my ($widget,$code,$key,$mod) = @_;
    say q(You released '), chr $code, q(');
}

Prima->run;

If I hit and release the '9' key on the numeric keypad, I get:

You pressed '9'
You released '3'

I have no idea why the key press is not affected but releasing the same key is, but that entry in unix/event.c looks suspicious. After applying the patch, I get

You pressed '9'
You released '9'
dk commented 1 year ago

nice catch, thanks!