| Ticket UUID: | 52e9b0f52cb833b05d91bcb75b5e1345722418a4 | |||
| Title: | keysyms for non-ascii bound keys are missing | |||
| Type: | Support | Version: | http://core.tcl.tk/tk/info/fa61f24c161f4422 | |
| Submitter: | budden | Created on: | 2017-05-30 19:57:47 | |
| Subsystem: | 32. Key Symbols | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-09-23 08:37:03 | |
| Resolution: | Fixed | Closed By: | oehhar | |
| Closed on: | 2026-09-23 08:37:03 | |||
| Description: |
In 8.6.6, I had keysyms for cyrillic characters. They were platform-dependent (and maybe even keyboard-layout dependent), but at least I had something. So I could create a binding for key combinations like Control-Shift-Ю . In the current trunk (see "Version" field in the ticket), all keys like this have a keysym of "??", so my key combinations do not work any more. At least this happend in Windows. Relevant discussion is here: http://wiki.tcl.tk/6182 Part of one of one possible solutions is here: http://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c (Public Domain). | |||
| User Comments: |
oehhar added on 2026-09-23 08:37:03:
The German Umlaut Unicode instead keysym %K reporting was moved to ticket [014f452d]. oehhar added on 2026-09-23 08:14:17: Branch merged to branch:
Bug closed. Thanks for all, Harald serhiy.storchaka added on 2026-09-22 20:36:22: Thank you, your hypothesis was right: switching the keyboard layout releases the modifiers of the key which switches it, and that KeyRelease event is recorded by the test. Fixed in [62fc028873]: the event loop is now run after switching the layout, before the bindings are set. oehhar added on 2026-09-22 18:57:32: Tried the tess locally. Here is the result:
==== event-8.7 keysym of a non-Latin key on Windows - bug 52e9b0f52c FAILED
==== Contents of test case:
set t [toplevel .t]
set e [entry $t.e]
pack $e
update
testsendinput foreground $e
focus -force $e
update
# Ukrainian layout: the Q key is Cyrillic_shorti.
testsendinput layout 00000422
bind $e <Key> {lappend res [list press %K]}
bind $e <KeyRelease> {lappend res [list release %K]}
bind $t <Cyrillic_shorti> {lappend res matched}
testsendinput key 0x51
# Wait for the events to arrive.
after 500 {set done 1}
vwait done
set res
---- Result was:
{release Control_L} {press Cyrillic_shorti} matched {release Cyrillic_shorti}
---- Result should have been (exact matching):
{press Cyrillic_shorti} matched {release Cyrillic_shorti}
==== event-8.7 FAILED
---- event-8.8 start
==== event-8.8 keysym of a key without a named keysym on Windows - bug 52e9b0f52c FAILED
==== Contents of test case:
set t [toplevel .t]
set e [entry $t.e]
pack $e
update
testsendinput foreground $e
focus -force $e
update
# Georgian layout: the Q key is U+10E6 (Georgian_ghan on X11, which
# has no name in Tk).
testsendinput layout 00000437
bind $e <Key> {lappend res [list press %K]}
bind $e <KeyRelease> {lappend res [list release %K]}
bind $t <\u10E6> {lappend res matched}
testsendinput key 0x51
# Wait for the events to arrive.
after 500 {set done 1}
vwait done
set res
---- Result was:
{release Control_L} {press \u10E6} matched {release \u10E6}
---- Result should have been (exact matching):
{press \u10E6} matched {release \u10E6}
==== event-8.8 FAILED
So, there is an additional "{release Control_L}". I suppose, this is due to the keyboard language change. At least on the greek keyboard, the left control key is used to switch between latin and greek. Nevertheless, the test result looks good. So modifying the test to be agnostic to the {release Control_L} would be ok for me. Thanks for all, Harald oehhar added on 2026-09-22 15:52:26: Made some tries with bindings with tcl8.6, tcl9.0.4 and the bugfix branch. Test 1: bind . <odiaeresis> "puts odiaeresis" -> Press "ö" key on German keyboard Result: Works on all three versions Test 2: bind . <ö> "puts ö" -> Press "ö" key on German keyboard Results:
Test 3: bind . <Greek_alpha> "puts Greek_alpha" -> Press "α" key on Greek keyboard Results:
Test 4: bind . <α> "puts α" -> Press "α" key on Greek keyboard Results:
Conclusions:
Thanks for all, great. Take care, Harald serhiy.storchaka added on 2026-09-22 06:29:42: Added tests in [699de24d58]: event-8.7 (Ukrainian layout: %K is Cyrillic_shorti and a <Cyrillic_shorti> binding fires for the Q key), event-8.8 (Georgian layout: a character without a named keysym gets the Unicode keysym, %K is the character itself) and event-8.9 (event generate with non-Latin keysyms). They use a new test command testsendinput (win/tkWinTest.c) which injects keyboard input with SendInput() and loads/activates a keyboard layout by its identifier; the layouts do not need to be installed. The tests found that the table in tkUnicodeKeysyms.h (moved from tkMacOSXKeysyms.h) has pre-2004 X keysym values for Armenian, Georgian, Vietnamese, Latin-8, Latin-9, Farsi, Arabic and Cyrillic extension characters and currency signs (338 entries), which neither ks_names.h nor keysymdef.h know, so %K was still "??" for them and bindings by name or by character could not match. Fixed in [577a24a74c] by using the current values (Unicode keysyms 0x1000000 + code point). This also affects macOS, which uses the same table. The same testsendinput command is added on the branches for [a9bd2ab98b], [f492c3de04] and [2225507]. Merging them will conflict in win/tkWinTest.c and tests/constraints.tcl: keep one copy of the command and the constraint (they are identical), and keep the tests of all branches (their numbers do not overlap). oehhar added on 2026-09-21 15:55:42: Tried with the proposed script:
bind . <Key> {puts "%%k=%k %%K=%K %%s=%s %%A=%A"}
on Win11 with German and Greek keyboard and the on screen keyboard (as it shows the Greek glyphs on the keys). Tested Tk is 8.6.15, 9.0.5 and the bugfix branch Results are: German keyboard "ö"
Greek keyboard "α"
The bugfix is clearly an improvement. I found it interesting that for German special characters "ÄÖÜäöüß", the %K changed from a descriptive name to the character. Independent on this bugfix, I am questioning myself, if this is a bug or a feature. Anyway, I will merge to main if CI ok. Thanks for all, Harald serhiy.storchaka added on 2026-09-17 21:15:51:
Note that with Control or Alt held the keysym is the Latin letter of the key (branch win-nonlatin-shortcuts-main, [433261290b]), as on X11 and in other Windows applications, so a shortcut on the ю key is budden added on 2017-05-31 19:18:16: Script itself is the following:
set keysym "********* [encoding system] *********"
encoding system utf-8
package require Tk
pack [label .l -textvariable keysym -padx 2m -pady 1m]
bind . <Key> {
set keysym "You pressed %k %K %s %A"
}
budden added on 2017-05-31 15:41:11: https://youtu.be/6FJAvbeCVTk dgp added on 2017-05-31 13:13:15: can a demonstration script be added as a comment, or an attachment, so a non-expert has at least a chance to understand what the problem is? Thanks. budden added on 2017-05-31 12:08:34: One (imperfect) solution is to make Keycode_NNN pseudo-keysyms for bindings which enter into play when no other ways of convert keycode to keysym help. So <Control-Key-Keycode_1022> pattern corresponds to Control-ю (Control-Cyrillic yu).
This solution is imperfect because:
1. There can be conflicts between Keycode_ bindings and traditional X keysym names, that is, the same number will have different meaning as a Keycode_ binding and as a named X keysym.
2. Dead keys and keys entered with AltGr are not processed correctly. E.g. in my current Russian layout just q is cyrillic й, while sequence of =q is just q, but my й binding still fires. I believe this is not a problem of my decision, but issue in some other place.
3. There is no %К expansion for those keys.
Patch is relative to http://core.tcl.tk/tk/info/fa61f24c161f4422
--- f:/downloads/tcl867rc/87/generic/tkBind.c Mon May 29 16:50:02 2017
+++ c:/yar/tcl-8.6.6/build/tk8.6.6/generic/tkBind.c Wed May 31 14:06:32 2017
@@ -4251,6 +4251,9 @@
}
}
#endif /* REDO_KEYSYM_LOOKUP */
+ if (!strncmp("Keycode_",name,8)) {
+ return ((KeySym)atoi(name+8));
+ }
return XStringToKeysym(name);
}
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki