From c23bc2d2a5509e727bcdda3ccf90783a10241c50 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Fri, 3 Mar 2017 17:46:21 +0100 Subject: [PATCH] Handle copy/paste commands by default on Mac (#161) --- src/handlers/keyboard_handler.pyx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/handlers/keyboard_handler.pyx b/src/handlers/keyboard_handler.pyx index 6391d74b..b0b03f53 100644 --- a/src/handlers/keyboard_handler.pyx +++ b/src/handlers/keyboard_handler.pyx @@ -90,7 +90,20 @@ cdef public cpp_bool KeyboardHandler_OnKeyEvent( browser=pyBrowser, event=pyEvent, event_handle=PyLong_FromVoidPtr(cefEventHandle)) - return bool(returnValue) + # If returnValue is False then handle copy/paste on Mac + if returnValue: + return bool(returnValue) + if platform.system() == "Darwin": + # Handle copy: command + c + if pyEvent["modifiers"] == 128 \ + and pyEvent["native_key_code"] == 8: + pyBrowser.GetFocusedFrame().Copy() + return True + # Handle paste: command + v + elif pyEvent["modifiers"] == 128 \ + and pyEvent["native_key_code"] == 9: + pyBrowser.GetFocusedFrame().Paste() + return True return False except: (exc_type, exc_value, exc_trace) = sys.exc_info()