Skip to content

Commit 51a9373

Browse files
authored
Merge 3a96c9d into c379885
2 parents c379885 + 3a96c9d commit 51a9373

3 files changed

Lines changed: 30 additions & 7 deletions

File tree

source/NVDAObjects/IAccessible/winword.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
from ..behaviors import EditableTextWithoutAutoSelectDetection
2424
import NVDAObjects.window.winword as winWordWindowModule
2525
from speech import sayAll
26+
import api
27+
import inputCore
28+
from typing import Callable
2629

2730

2831
class WordDocument(IAccessible, EditableTextWithoutAutoSelectDetection, winWordWindowModule.WordDocument):
@@ -47,12 +50,7 @@ def _get_ignoreEditorRevisions(self):
4750
ignoreFormatting=False
4851

4952
def event_caret(self):
50-
curSelectionPos=self.makeTextInfo(textInfos.POSITION_SELECTION)
51-
lastSelectionPos=getattr(self,'_lastSelectionPos',None)
52-
self._lastSelectionPos=curSelectionPos
53-
if lastSelectionPos:
54-
if curSelectionPos._rangeObj.isEqual(lastSelectionPos._rangeObj):
55-
return
53+
self._lastSelectionPos = self.makeTextInfo(textInfos.POSITION_SELECTION)
5654
super(WordDocument,self).event_caret()
5755

5856
def _get_role(self):
@@ -369,6 +367,21 @@ def script_previousParagraph(self,gesture):
369367
self._caretScriptPostMovedHelper(textInfos.UNIT_PARAGRAPH,gesture,None)
370368
script_previousParagraph.resumeSayAllMode = sayAll.CURSOR.CARET
371369

370+
def script_paste(self, gesture: inputCore.InputGesture) -> None:
371+
"""Helper script to update braille and review position."""
372+
gesture.send()
373+
self._updateBraille()
374+
375+
def _updateBraille(self) -> None:
376+
"""Update braille and review position when helper scripts like script_paste are executed."""
377+
# Using getFocusObject because self does not work always.
378+
if not eventHandler.isPendingEvents("caret", api.getFocusObject()):
379+
eventHandler.queueEvent("caret", api.getFocusObject())
380+
log.debug(f"{self.appModule.appName}: enqueued caret event")
381+
382+
script_cut: Callable[[inputCore.InputGesture], None] = script_paste
383+
script_undo: Callable[[inputCore.InputGesture], None] = script_paste
384+
372385
def focusOnActiveDocument(self, officeChartObject):
373386
rangeStart=officeChartObject.Parent.Range.Start
374387
self.WinwordApplicationObject.ActiveDocument.Range(rangeStart, rangeStart).Select()
@@ -390,6 +403,9 @@ def focusOnActiveDocument(self, officeChartObject):
390403
"kb:alt+pageUp":"caret_moveByCell",
391404
"kb:alt+pageDown":"caret_moveByCell",
392405
"kb:NVDA+alt+c":"reportCurrentComment",
406+
"kb:control+v": "paste",
407+
"kb:control+x": "cut",
408+
"kb:control+z": "undo",
393409
}
394410

395411

source/NVDAObjects/UIA/wordDocument.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
)
3737
from NVDAObjects import NVDAObject
3838
from scriptHandler import script
39+
import eventHandler
3940

4041

4142
"""Support for Microsoft Word via UI Automation."""
@@ -544,7 +545,10 @@ class WordDocument(UIADocumentWithTableNavigation,WordDocumentNode,WordDocumentB
544545
def event_textChange(self):
545546
# Ensure Braille is updated when text changes,
546547
# As Microsoft Word does not fire caret events when typing text, even though the caret does move.
547-
braille.handler.handleCaretMove(self)
548+
# Update braille also when tethered to review, and review position
549+
# if review follows caret.
550+
if not eventHandler.isPendingEvents("caret", self):
551+
eventHandler.queueEvent("caret", self)
548552

549553
def event_UIA_notification(self, activityId=None, **kwargs):
550554
# #10851: in recent Word 365 releases, UIA notification will cause NVDA to announce edit functions

user_docs/en/changes.t2t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ What's New in NVDA
1818
== Bug Fixes ==
1919
- Reporting of object shortcut keys has been improved. (#10807)
2020
- The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271)
21+
- Braille is updated when control+v, control+x, control+z or backspace is pressed.
22+
It is also updated when typing text, and braille is tethered to review and
23+
review follows caret. (#3276)
2124
-
2225

2326
== Changes for Developers ==

0 commit comments

Comments
 (0)