Hi,

In an event handler of a text field I try to get and print (for testing) the 
key code and the modifiers using something like:

sub OnKeyCombinations {
  my ($key_combination, $event) = @_;

  my $key = $event->GetKeyCode;
  my $modifiers = $event->GetModifiers;

$key_combination->SetValue("key: $key, mod: $modifiers");
}

There are 2 problems. One is the fact that the Alt key is not detected at all 
with this code, and the other one is that the key code is changed if the 
Control key is used and I don't know how to find the real key pressed.

For example, here are the key pressed, and the results:

p: key: 112, mod: 0
Shift+p: key: 80, mod: 4
Control+p: key: 16, mod: 2
Control+Shift+p: key: 16, mod: 6
Alt+p: no change, a short beep because there is no accelerator key defined as 
Alt+p, the keypress is not detected)
Control+Alt+p: (no change, no beep, the keypress is not detected)

The modifiers are detected correctly if I use only Control and Shift. They give 
the result 2, 4 and 6 but the Alt key is not detected although it should be.

The key code changes if I press the Control key from 80 to 16 and I don't know 
how to find the pressed key if the Control modifier was pressed.

I have also put a die() in this event handler but the program doesn't break if 
I use a key combination that contains the Alt key, so it is obviously not 
detected.

In WxPerl manual I read:

"Note for Windows programmers: The key and char events in wxWidgets are similar 
to but slightly different from Windows WM_KEYDOWN and WM_CHAR events. In 
particular, Alt-x combination will generate a char event in wxWidgets (unless 
it is used as an accelerator)."

I use ActivePerl 5.10.1 under Windows XP and WxPerl 0.98.

Am I missing something or doing something wrong?

Thanks.

Octavian

Reply via email to