|
36 | 36 | ) |
37 | 37 | from NVDAObjects import NVDAObject |
38 | 38 | from scriptHandler import script |
| 39 | +import api |
| 40 | +import eventHandler |
39 | 41 |
|
40 | 42 |
|
41 | 43 | """Support for Microsoft Word via UI Automation.""" |
@@ -544,14 +546,26 @@ class WordDocument(UIADocumentWithTableNavigation,WordDocumentNode,WordDocumentB |
544 | 546 | def event_textChange(self): |
545 | 547 | # Ensure Braille is updated when text changes, |
546 | 548 | # As Microsoft Word does not fire caret events when typing text, even though the caret does move. |
547 | | - braille.handler.handleCaretMove(self) |
| 549 | + # Update braille also when tethered to review, and review position |
| 550 | + # if review follows caret. |
| 551 | + if not eventHandler.isPendingEvents("caret", self): |
| 552 | + eventHandler.queueEvent("caret", self) |
548 | 553 |
|
549 | 554 | def event_UIA_notification(self, activityId=None, **kwargs): |
550 | 555 | # #10851: in recent Word 365 releases, UIA notification will cause NVDA to announce edit functions |
551 | 556 | # such as "delete back word" when Control+Backspace is pressed. |
552 | 557 | if activityId == "AccSN2": # Delete activity ID |
553 | 558 | return |
554 | 559 | super(WordDocument, self).event_UIA_notification(**kwargs) |
| 560 | + # Try to ensure that braille is updated when UIA is not used and |
| 561 | + # ctrl-v, ctrl-x or ctrl-z is pressed. |
| 562 | + # Using getFocusObject because self does not work always. |
| 563 | + if ( |
| 564 | + not UIAHandler.shouldUseUIAInMSWord(self.appModule) |
| 565 | + and not eventHandler.isPendingEvents("caret", api.getFocusObject()) |
| 566 | + ): |
| 567 | + eventHandler.queueEvent("caret", api.getFocusObject()) |
| 568 | + log.debug(f"{self.appModule.appName}: enqueued caret event") |
555 | 569 |
|
556 | 570 | # The following overide of the EditableText._caretMoveBySentenceHelper private method |
557 | 571 | # Falls back to the MS Word object model if available. |
|
0 commit comments