Tk Source Code

View Ticket
Login
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: Open Last Modified: 2017-05-31 19:18:16
Resolution: None Closed By: nobody
    Closed on:
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: 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);
 }