in reply to Re^3: Windows Tk issue Copy and Paste Russian keyboard
in thread Windows Tk issue Copy and Paste Russian keyboard

I am a bit confused. In all applications I have tried (Browser for example) I can switch keyboard layout and use Ctrl-C/V (I mean the same physical keys, not the value mapped to it) and copy and paste continues to work (I have tried with Russian, Greek, Chinese and so on). In a Tk Widget, this is not true anymore (Russian and Greek do not work anymore). As far as my (Russian) colleagues have reported that Russian copy and paste should work on Windows using the same (physical) keys we are accustomed to.

If things are like this and this is not a bug, doeas it mean I need to add a bind to map a particular shortcut to copy/paste? This will a) need me to know the current keyboard layout (as far as I know there is no way to get it programmatically) b) code a way to perform the copy/paste operation. This sounds like quite a lot of job to have copy and paste on other layouts then Latin keyboards. Am I overseeing something?

Replies are listed 'Best First'.
Re^5: Windows Tk issue Copy and Paste Russian keyboard
by Corion (Patriarch) on May 20, 2019 at 12:57 UTC

    I'm not in a position to test this, but the internet suggests that Tk can also bind to a keycode, not only a character, but the solutions seem to be to bind to all keys using KeyPress and then to look at the keycode in the event.

      Yes, it is possible. The following code reads the keycode:

      use strict; use warnings; use Tk; my $name; my $mw = MainWindow->new(); my $entry = $mw->Entry( -textvariable => \$name )->pack(); $mw->bind("<KeyRelease>" => sub { warn $_[0]->XEvent->k; }); $mw->MainLoop(); exit(0);

      I should then mimic the combination of Ctrl+C/V, and the copy and paste rutines. I am not sure if this is the way to go, but at the moment it seems the only alternative to use copy and paste in Tk with all (?) keyboard layouts.