From f7a76a316768f764daaa10006847d1f6de8a6ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=91=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=80=D0=B5=D0=B2?= Date: Wed, 20 May 2026 23:40:58 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20macOS=20Cmd+V=20paste=20=E2=80=94=20bind?= =?UTF-8?q?=20=20directly=20(Tk=208.6=20bug)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- ssh_manager.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ssh_manager.py b/ssh_manager.py index 3449962..6639f97 100644 --- a/ssh_manager.py +++ b/ssh_manager.py @@ -492,10 +492,10 @@ def agent_search(query): def setup_entry_clipboard(entry): - """Add right-click context menu to tk.Entry. Keyboard shortcuts (Cmd+V/C/X) - are handled by tkinter's built-in Entry bindings — do NOT override them.""" + """Fix clipboard on macOS (Tk 8.6 maps <> to Mod1 not Command) + and add right-click context menu.""" - def _paste(): + def _paste(e=None): try: text = entry.clipboard_get() if entry.selection_present(): @@ -503,20 +503,24 @@ def setup_entry_clipboard(entry): entry.insert(tk.INSERT, text) except tk.TclError: pass + return "break" - def _copy(): + def _copy(e=None): if entry.selection_present(): entry.clipboard_clear() entry.clipboard_append(entry.selection_get()) + return "break" - def _cut(): + def _cut(e=None): + _copy() if entry.selection_present(): - _copy() entry.delete(tk.SEL_FIRST, tk.SEL_LAST) + return "break" - def _select_all(): + def _select_all(e=None): entry.select_range(0, tk.END) entry.icursor(tk.END) + return "break" def _context_menu(event): menu = tk.Menu(entry, tearoff=0, bg="#313244", fg="#cdd6f4", @@ -528,12 +532,19 @@ def setup_entry_clipboard(entry): menu.add_command(label="Выделить всё", command=_select_all) menu.tk_popup(event.x_root, event.y_root) - # Right-click context menu only — keyboard handled by tkinter defaults - entry.bind("", _context_menu) if sys.platform == "darwin": + # macOS Tk 8.6 bug: <> bound to Mod1 (Option) not Command + # Manually bind Command+key for clipboard operations + entry.bind("", _paste) + entry.bind("", _copy) + entry.bind("", _cut) + entry.bind("", _select_all) + # Right-click entry.bind("", _context_menu) entry.bind("", _context_menu) + entry.bind("", _context_menu) + def app_dir(): if getattr(sys, "frozen", False):