Skip to content

Commit c23bc2d

Browse files
committed
Handle copy/paste commands by default on Mac (cztomczak#161)
1 parent 23a6c62 commit c23bc2d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/handlers/keyboard_handler.pyx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,20 @@ cdef public cpp_bool KeyboardHandler_OnKeyEvent(
9090
browser=pyBrowser,
9191
event=pyEvent,
9292
event_handle=<object>PyLong_FromVoidPtr(cefEventHandle))
93-
return bool(returnValue)
93+
# If returnValue is False then handle copy/paste on Mac
94+
if returnValue:
95+
return bool(returnValue)
96+
if platform.system() == "Darwin":
97+
# Handle copy: command + c
98+
if pyEvent["modifiers"] == 128 \
99+
and pyEvent["native_key_code"] == 8:
100+
pyBrowser.GetFocusedFrame().Copy()
101+
return True
102+
# Handle paste: command + v
103+
elif pyEvent["modifiers"] == 128 \
104+
and pyEvent["native_key_code"] == 9:
105+
pyBrowser.GetFocusedFrame().Paste()
106+
return True
94107
return False
95108
except:
96109
(exc_type, exc_value, exc_trace) = sys.exc_info()

0 commit comments

Comments
 (0)