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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user