Tk Source Code

Check-in [4a7d6f6b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix [a9bd2ab98b], [f492c3de04]: keyboard input on Windows

Backport of the fixes from 9.0 and 9.1.

A WM_KEYDOWN message with VK_PACKET, sent for a character entered via an input method or the touch keyboard, was re-posted with the character as the virtual key code, so the KeyPress event had the keysym of a function key. Now no events are generated for the VK_PACKET key itself; the WM_CHAR message produced by TranslateMessage() generates the key events.

GetTranslatedKey() retrieved the WM_CHAR messages with GetMessageA(), so Windows converted the characters to the code page of the keyboard layout, and TkpGetString() decoded them with a code page guessed from the input language. When the two differed, the typed characters were mangled. Now the messages are retrieved as Unicode and the characters are stored as UTF-8 in the key event, and the code page machinery is removed.

Tests event-8.4, event-8.5 and event-8.6, and the missing testsendinput constraint.

Downloads: See separate download page
Timelines: family | ancestors | descendants | both | core-8-6-branch
Files: files | file ages | folders
SHA3-256: 4a7d6f6b760e7938cb60dee069fe29e44d5d161e9948bfb7830035db2157cce8
User & Date: serhiy.storchaka 2026-09-23 08:04:37.660
References
2026-10-26
17:30 • Closed ticket [6c0d7aec]: unicode text input plus 5 other changes artifact: 3323371d user: serhiy.storchaka
2026-10-23
10:16 • Closed ticket [2839285f]: MS Windows: Input: chars ĉ, ĝ, ĵ, ... come out as c, g, j... plus 6 other changes artifact: 47f8966f user: serhiy.storchaka
2026-09-23
08:33 • Ticket [a9bd2ab9] Partial WM_INPUTLANGCHANGE support ignores keyboard layout changes status still Closed with 3 other changes artifact: 74ec9f8f user: serhiy.storchaka
08:33 • Ticket [f492c3de] MS-Win: characters entered via an IME or the touch keyboard get the keysym of a function key (F1, F3, F5, ...) status still Closed with 3 other changes artifact: 677d26a0 user: serhiy.storchaka
Context
2026-09-23
08:25
On macOS, do not replace the signal handlers of the embedding application

Backport of [87fa518cee] from 9.0 and 9.1: the SIGINT, SIGHUP and SIGTERM handlers are only installed if the application which embeds Tk has not installed its own (e.g. Python raises KeyboardInterrupt from its SIGINT handler). check-in: c505fe41 user: serhiy.storchaka tags: core-8-6-branch

08:04
Fix [a9bd2ab98b], [f492c3de04]: keyboard input on Windows

Backport of the fixes from 9.0 and 9.1.

A WM_KEYDOWN message with VK_PACKET, sent for a character entered via an input method or the touch keyboard, was re-posted with the character as the virtual key code, so the KeyPress event had the keysym of a function key. Now no events are generated for the VK_PACKET key itself; the WM_CHAR message produced by TranslateMessage() generates the key events.

GetTranslatedKey() retrieved the WM_CHAR messages with GetMessageA(), so Windows converted the characters to the code page of the keyboard layout, and TkpGetString() decoded them with a code page guessed from the input language. When the two differed, the typed characters were mangled. Now the messages are retrieved as Unicode and the characters are stored as UTF-8 in the key event, and the code page machinery is removed.

Tests event-8.4, event-8.5 and event-8.6, and the missing testsendinput constraint. check-in: 4a7d6f6b user: serhiy.storchaka tags: core-8-6-branch

2026-09-22
14:11
Fix [9e89324a0a]: spinbox parsing depends on the LC_NUMERIC locale check-in: e0dd3fdb user: jan.nijtmans tags: core-8-6-branch
Changes
Unified Diff Side-by-Side Diff Patch
Changes to generic/tkInt.h.
Changes to tests/constraints.tcl.
Changes to tests/event.test.
Changes to win/tkWinInt.h.
Changes to win/tkWinKey.c.
Changes to win/tkWinX.c.