|
2 | 2 | # License: New BSD License. |
3 | 3 | # Website: http://code.google.com/p/cefpython/ |
4 | 4 |
|
| 5 | +# cef_key_type_t, SendKeyEvent(). |
| 6 | +KEYTYPE_KEYUP = cef_types.KT_KEYUP |
| 7 | +KEYTYPE_KEYDOWN = cef_types.KT_KEYDOWN |
| 8 | +KEYTYPE_CHAR = cef_types.KT_CHAR |
| 9 | + |
| 10 | +# cef_mouse_button_type_t, SendMouseClickEvent(). |
| 11 | +MOUSEBUTTON_LEFT = cef_types.MBT_LEFT |
| 12 | +MOUSEBUTTON_MIDDLE = cef_types.MBT_MIDDLE |
| 13 | +MOUSEBUTTON_RIGHT = cef_types.MBT_RIGHT |
| 14 | + |
5 | 15 | # If you try to keep PyBrowser() objects inside cpp_vector you will |
6 | 16 | # get segmentation faults, as they will be garbage collected. |
7 | 17 |
|
@@ -272,6 +282,9 @@ cdef class PyBrowser: |
272 | 282 | preinc(iterator) |
273 | 283 | return names |
274 | 284 |
|
| 285 | + cpdef int GetIdentifier(self) except *: |
| 286 | + return self.GetCefBrowser().get().GetIdentifier() |
| 287 | + |
275 | 288 | cpdef PyFrame GetMainFrame(self): |
276 | 289 | return GetPyFrame(self.GetCefBrowser().get().GetMainFrame()) |
277 | 290 |
|
@@ -512,20 +525,44 @@ cdef class PyBrowser: |
512 | 525 |
|
513 | 526 | IF CEF_VERSION == 1: |
514 | 527 |
|
515 | | - cpdef py_void SendKeyEvent(self): |
516 | | - pass |
| 528 | + cpdef py_void SendKeyEvent(self, cef_types.cef_key_type_t keyType, |
| 529 | + tuple keyInfo, int modifiers): |
| 530 | + cdef CefKeyInfo cefKeyInfo |
| 531 | + IF UNAME_SYSNAME == "Windows": |
| 532 | + assert len(keyInfo) == 3, "Invalid keyInfo param" |
| 533 | + cefKeyInfo.key = keyInfo[0] |
| 534 | + cefKeyInfo.sysChar = keyInfo[1] |
| 535 | + cefKeyInfo.imeChar = keyInfo[2] |
| 536 | + ELIF UNAME_SYSNAME == "Darwin": |
| 537 | + cefKeyInfo.keyCode = keyInfo[0] |
| 538 | + cefKeyInfo.character = keyInfo[1] |
| 539 | + cefKeyInfo.characterNoModifiers = keyInfo[2] |
| 540 | + ELIF UNAME_SYSNAME == "Linux": |
| 541 | + cefKeyInfo.key = keyInfo[0] |
| 542 | + ELSE: |
| 543 | + raise Exception("Invalid UNAME_SYSNAME") |
| 544 | + |
| 545 | + self.GetCefBrowser().get().SendKeyEvent(keyType, cefKeyInfo, |
| 546 | + modifiers) |
517 | 547 |
|
518 | | - cpdef py_void SendMouseClickEvent(self): |
519 | | - pass |
| 548 | + cpdef py_void SendMouseClickEvent(self, int x, int y, |
| 549 | + cef_types.cef_mouse_button_type_t mouseButtonType, |
| 550 | + py_bool mouseUp, int clickCount): |
| 551 | + self.GetCefBrowser().get().SendMouseClickEvent(x, y, |
| 552 | + mouseButtonType, bool(mouseUp), clickCount) |
520 | 553 |
|
521 | | - cpdef py_void SendMouseMoveEvent(self): |
522 | | - pass |
| 554 | + cpdef py_void SendMouseMoveEvent(self, int x, int y, |
| 555 | + py_bool mouseLeave): |
| 556 | + self.GetCefBrowser().get().SendMouseMoveEvent(x, y, |
| 557 | + bool(mouseLeave)) |
523 | 558 |
|
524 | | - cpdef py_void SendMouseWheelEvent(self): |
525 | | - pass |
| 559 | + cpdef py_void SendMouseWheelEvent(self, int x, int y, |
| 560 | + int deltaX, int deltaY): |
| 561 | + self.GetCefBrowser().get().SendMouseWheelEvent(x, y, |
| 562 | + deltaX, deltaY) |
526 | 563 |
|
527 | | - cpdef py_void SendFocusEvent(self): |
528 | | - pass |
| 564 | + cpdef py_void SendFocusEvent(self, py_bool setFocus): |
| 565 | + self.GetCefBrowser().get().SendFocusEvent(bool(setFocus)) |
529 | 566 |
|
530 | 567 | cpdef py_void SendCaptureLostEvent(self): |
531 | | - pass |
| 568 | + self.GetCefBrowser().get().SendCaptureLostEvent() |
0 commit comments