v1.8.23: fix Ctrl+V/C/X/A/Z for non-Latin keyboard layouts, add Entry undo/redo
- Global keycode-based handler for Ctrl shortcuts (works with Russian, Chinese, any layout) - Tkinter maps <<Paste>> to <Control-v> by keysym which fails on non-Latin layouts - New handler intercepts <Control-Key> at 'all' level, checks keycodes and generates correct virtual events - Added Undo/Redo support for Entry widgets (tk.Entry has no built-in undo) - Tab switch focus management: terminal releases focus when switching away Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,6 @@ def enable_undo(ctk_entry):
|
||||
if not history or history[-1] != val:
|
||||
history.append(val)
|
||||
redo_stack.clear()
|
||||
# Cap history size
|
||||
if len(history) > 200:
|
||||
del history[:100]
|
||||
|
||||
@@ -46,15 +45,6 @@ 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)
|
||||
entry.bind("<Control-Key>", _on_ctrl_key)
|
||||
|
||||
Reference in New Issue
Block a user