Skip to content

Commit

Permalink
Handle copy/paste commands by default on Mac (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed Mar 3, 2017
1 parent 23a6c62 commit c23bc2d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/handlers/keyboard_handler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,20 @@ cdef public cpp_bool KeyboardHandler_OnKeyEvent(
browser=pyBrowser,
event=pyEvent,
event_handle=<object>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()
Expand Down

0 comments on commit c23bc2d

Please sign in to comment.