Skip to content

Commit

Permalink
Merge 3a96c9d into c379885
Browse files Browse the repository at this point in the history
  • Loading branch information
burmancomp authored Sep 26, 2023
2 parents c379885 + 3a96c9d commit 51a9373
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
28 changes: 22 additions & 6 deletions source/NVDAObjects/IAccessible/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from ..behaviors import EditableTextWithoutAutoSelectDetection
import NVDAObjects.window.winword as winWordWindowModule
from speech import sayAll
import api
import inputCore
from typing import Callable


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

def event_caret(self):
curSelectionPos=self.makeTextInfo(textInfos.POSITION_SELECTION)
lastSelectionPos=getattr(self,'_lastSelectionPos',None)
self._lastSelectionPos=curSelectionPos
if lastSelectionPos:
if curSelectionPos._rangeObj.isEqual(lastSelectionPos._rangeObj):
return
self._lastSelectionPos = self.makeTextInfo(textInfos.POSITION_SELECTION)
super(WordDocument,self).event_caret()

def _get_role(self):
Expand Down Expand Up @@ -369,6 +367,21 @@ def script_previousParagraph(self,gesture):
self._caretScriptPostMovedHelper(textInfos.UNIT_PARAGRAPH,gesture,None)
script_previousParagraph.resumeSayAllMode = sayAll.CURSOR.CARET

def script_paste(self, gesture: inputCore.InputGesture) -> None:
"""Helper script to update braille and review position."""
gesture.send()
self._updateBraille()

def _updateBraille(self) -> None:
"""Update braille and review position when helper scripts like script_paste are executed."""
# Using getFocusObject because self does not work always.
if not eventHandler.isPendingEvents("caret", api.getFocusObject()):
eventHandler.queueEvent("caret", api.getFocusObject())
log.debug(f"{self.appModule.appName}: enqueued caret event")

script_cut: Callable[[inputCore.InputGesture], None] = script_paste
script_undo: Callable[[inputCore.InputGesture], None] = script_paste

def focusOnActiveDocument(self, officeChartObject):
rangeStart=officeChartObject.Parent.Range.Start
self.WinwordApplicationObject.ActiveDocument.Range(rangeStart, rangeStart).Select()
Expand All @@ -390,6 +403,9 @@ def focusOnActiveDocument(self, officeChartObject):
"kb:alt+pageUp":"caret_moveByCell",
"kb:alt+pageDown":"caret_moveByCell",
"kb:NVDA+alt+c":"reportCurrentComment",
"kb:control+v": "paste",
"kb:control+x": "cut",
"kb:control+z": "undo",
}


Expand Down
6 changes: 5 additions & 1 deletion source/NVDAObjects/UIA/wordDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
)
from NVDAObjects import NVDAObject
from scriptHandler import script
import eventHandler


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

def event_UIA_notification(self, activityId=None, **kwargs):
# #10851: in recent Word 365 releases, UIA notification will cause NVDA to announce edit functions
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ What's New in NVDA
== Bug Fixes ==
- Reporting of object shortcut keys has been improved. (#10807)
- The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271)
- Braille is updated when control+v, control+x, control+z or backspace is pressed.
It is also updated when typing text, and braille is tethered to review and
review follows caret. (#3276)
-

== Changes for Developers ==
Expand Down

0 comments on commit 51a9373

Please sign in to comment.