Skip to content

Commit 9cdda72

Browse files
committed
Merge pull request cztomczak#186 from rentouch/master
Ability to pass modifiers to SendMouseMoveEvent and similar (Issue cztomczak#182)
2 parents 0c1edf0 + bb81139 commit 9cdda72

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

cefpython/browser.pyx

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -696,17 +696,17 @@ cdef class PyBrowser:
696696

697697
cpdef py_void SendMouseClickEvent(self, int x, int y,
698698
cef_types.cef_mouse_button_type_t mouseButtonType,
699-
py_bool mouseUp, int clickCount):
699+
py_bool mouseUp, int clickCount, int modifiers=0):
700700
self.GetCefBrowser().get().SendMouseClickEvent(x, y,
701701
mouseButtonType, bool(mouseUp), clickCount)
702702

703703
cpdef py_void SendMouseMoveEvent(self, int x, int y,
704-
py_bool mouseLeave):
704+
py_bool mouseLeave, int modifiers=0):
705705
self.GetCefBrowser().get().SendMouseMoveEvent(x, y,
706706
bool(mouseLeave))
707707

708708
cpdef py_void SendMouseWheelEvent(self, int x, int y,
709-
int deltaX, int deltaY):
709+
int deltaX, int deltaY, int modifiers=0):
710710
self.GetCefBrowser().get().SendMouseWheelEvent(x, y,
711711
deltaX, deltaY)
712712

@@ -739,51 +739,31 @@ cdef class PyBrowser:
739739
bool(pyEvent["focus_on_editable_field"])
740740
self.GetCefBrowserHost().get().SendKeyEvent(cefEvent)
741741

742-
cpdef py_void SendMouseClickEvent(self, x, y,
742+
cpdef py_void SendMouseClickEvent(self, int x, int y,
743743
cef_types.cef_mouse_button_type_t mouseButtonType,
744-
py_bool mouseUp, int clickCount):
744+
py_bool mouseUp, int clickCount, int modifiers=0):
745745
cdef CefMouseEvent mouseEvent
746746
mouseEvent.x = x
747747
mouseEvent.y = y
748-
"""
749-
TODO: allow to pass modifiers which represents
750-
bit flags describing any pressed modifier keys.
751-
See cef_event_flags_t for values.
752-
enum cef_event_flags_t {
753-
EVENTFLAG_NONE = 0,
754-
EVENTFLAG_CAPS_LOCK_ON = 1 << 0,
755-
EVENTFLAG_SHIFT_DOWN = 1 << 1,
756-
EVENTFLAG_CONTROL_DOWN = 1 << 2,
757-
EVENTFLAG_ALT_DOWN = 1 << 3,
758-
EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4,
759-
EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5,
760-
EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6,
761-
// Mac OS-X command key.
762-
EVENTFLAG_COMMAND_DOWN = 1 << 7,
763-
EVENTFLAG_NUM_LOCK_ON = 1 << 8,
764-
EVENTFLAG_IS_KEY_PAD = 1 << 9,
765-
EVENTFLAG_IS_LEFT = 1 << 10,
766-
EVENTFLAG_IS_RIGHT = 1 << 11,
767-
"""
768-
mouseEvent.modifiers = 0
748+
mouseEvent.modifiers = modifiers
769749
self.GetCefBrowserHost().get().SendMouseClickEvent(mouseEvent,
770750
mouseButtonType, bool(mouseUp), clickCount)
771751

772752
cpdef py_void SendMouseMoveEvent(self, int x, int y,
773-
py_bool mouseLeave):
753+
py_bool mouseLeave, int modifiers=0):
774754
cdef CefMouseEvent mouseEvent
775755
mouseEvent.x = x
776756
mouseEvent.y = y
777-
mouseEvent.modifiers = 0
757+
mouseEvent.modifiers = modifiers
778758
self.GetCefBrowserHost().get().SendMouseMoveEvent(mouseEvent,
779759
bool(mouseLeave))
780760

781761
cpdef py_void SendMouseWheelEvent(self, int x, int y,
782-
int deltaX, int deltaY):
762+
int deltaX, int deltaY, int modifiers=0):
783763
cdef CefMouseEvent mouseEvent
784764
mouseEvent.x = x
785765
mouseEvent.y = y
786-
mouseEvent.modifiers = 0
766+
mouseEvent.modifiers = modifiers
787767
self.GetCefBrowserHost().get().SendMouseWheelEvent(mouseEvent,
788768
deltaX, deltaY)
789769

0 commit comments

Comments
 (0)