As I understand, Tk "emulates" X events when under Windows, and doesn't use MS-prescribed way to handle keyboard accelerators.
Check this line and function it resides in. Not sure I understand 100%, how come if I press "x" holding Ctrl, the function is called with same virtual keycode 88 for X key but (1) with "state" 8 for NumLock only and next (2) with "state" now 12 for Ctrl and NumLock. Return values are 120 (ascii x) and 24 (Ctrl-x).
Then it gets curiouser, whatever "keysym" this function returns appears to determine which, if any, accelerator to process, only. Keys pressed during "normal" input produce "normal" and expected characters displayed, regardless of changes I make, see further, to function. And more curioser, return "24" (in case of Ctrl-x) seems to be ignored and unused. But "keysym" returned for as-if-without-Ctrl call is important.
If you are still with me, the linked line misses the fact that under Latin and non-Latin kb-layouts, for the same virtual keycode (e.g. 88 for X key), the ToAscii populates 1st byte of "buf" with either 120 or 247, the latter is cyrillic "che" in CP1251 (these characters share the same key). So, with Russian kb-layout active, Ctrl-x doesn't cut in Tk.
Long story short, replace that line with:
static HKL USKB;
if (!(int)USKB) USKB = LoadKeyboardLayout("00000409", 0);
result = ToAsciiEx(keycode, scancode, keys, (LPWORD) buf, 0, USKB);
and then Ctrl-x, -c, -v work as expected under Russian layout, too. No idea if it's "right" way to fix the problem, though. Nor if it's acceptable for you to advise to compile Tk or distribute modified versions.
BTW, it's not true that "Ctrl-C" and friends work in Tk under US or any Latin keyboard. I mean, they don't if you press Ctrl-c with CapsLock active. Which doesn't contradict the description above and could be fixed if it bothers anybody (evidently not).
|