v1.8.13: fix entry_undo Cyrillic bind crash

tkinter rejects Cyrillic chars in bind(). Use keycode-based
<Control-Key> dispatch instead (same approach as terminal_widget).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chrome-storm-c442
2026-02-24 05:30:13 -05:00
parent afffc4177e
commit 5d55d41f34
2 changed files with 10 additions and 4 deletions

View File

@@ -46,9 +46,15 @@ def enable_undo(ctk_entry):
_recording[0] = True
return "break"
def _on_ctrl_key(event):
"""Route Ctrl+key by physical keycode (layout-independent)."""
if event.keycode == 90: # Z
return _undo(event)
if event.keycode == 89: # Y
return _redo(event)
return None
entry.bind("<KeyRelease>", _snapshot, add="+")
entry.bind("<Control-z>", _undo)
entry.bind("<Control-y>", _redo)
# Support Russian keyboard layout (Cyrillic keycodes)
entry.bind("<Control-\u044f>", _undo) # Ctrl+Я (z position on Russian layout)
entry.bind("<Control-\u043d>", _redo) # Ctrl+Н (y position on Russian layout)
entry.bind("<Control-Key>", _on_ctrl_key)