From 6c911aca2443e47c554bb6217182813ac0dbc8ee Mon Sep 17 00:00:00 2001 From: burmancomp Date: Thu, 21 Sep 2023 10:15:53 +0300 Subject: [PATCH 01/18] fix 3276 --- source/NVDAObjects/IAccessible/winword.py | 6 ------ source/NVDAObjects/UIA/wordDocument.py | 13 +++++++++++++ user_docs/en/changes.t2t | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index bffd4815748..56b82d2c651 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -47,12 +47,6 @@ 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 super(WordDocument,self).event_caret() def _get_role(self): diff --git a/source/NVDAObjects/UIA/wordDocument.py b/source/NVDAObjects/UIA/wordDocument.py index c8cbefb96c7..7486e0a2607 100644 --- a/source/NVDAObjects/UIA/wordDocument.py +++ b/source/NVDAObjects/UIA/wordDocument.py @@ -36,6 +36,9 @@ ) from NVDAObjects import NVDAObject from scriptHandler import script +import api +import config +from config.configFlags import TetherTo """Support for Microsoft Word via UI Automation.""" @@ -544,7 +547,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. + # Update braille also when tethered to review, and review position + # if review follows caret. braille.handler.handleCaretMove(self) + review.handleCaretMove(self) def event_UIA_notification(self, activityId=None, **kwargs): # #10851: in recent Word 365 releases, UIA notification will cause NVDA to announce edit functions @@ -552,6 +558,13 @@ def event_UIA_notification(self, activityId=None, **kwargs): if activityId == "AccSN2": # Delete activity ID return super(WordDocument, self).event_UIA_notification(**kwargs) + # Try to ensure that braille is updated when UIA is not used and + # ctrl-x or ctrl-z is pressed. + if config.conf["braille"]["tetherTo"] != TetherTo.REVIEW.value: + # Using getFocusObject because self does not work always. + braille.handler.handleCaretMove(api.getFocusObject()) + else: + braille.handler.handleReviewMove() # The following overide of the EditableText._caretMoveBySentenceHelper private method # Falls back to the MS Word object model if available. diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index ebe454d24ab..99d46547d74 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -16,6 +16,9 @@ What's New in NVDA == Bug Fixes == - Reporting of object shortcut keys has been improved. (#10807) +- Braille is updated when 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 == From 823daf641c8a276c32c2a371ce290abfe9c04714 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Tue, 26 Sep 2023 13:23:36 +0300 Subject: [PATCH 02/18] run added code when UIA should not be used, and minor modifications --- source/NVDAObjects/IAccessible/winword.py | 1 + source/NVDAObjects/UIA/wordDocument.py | 21 +++++++++++---------- user_docs/en/changes.t2t | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 56b82d2c651..2df07a4bb33 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -47,6 +47,7 @@ def _get_ignoreEditorRevisions(self): ignoreFormatting=False def event_caret(self): + self._lastSelectionPos = self.makeTextInfo(textInfos.POSITION_SELECTION) super(WordDocument,self).event_caret() def _get_role(self): diff --git a/source/NVDAObjects/UIA/wordDocument.py b/source/NVDAObjects/UIA/wordDocument.py index 7486e0a2607..b03c6d91b59 100644 --- a/source/NVDAObjects/UIA/wordDocument.py +++ b/source/NVDAObjects/UIA/wordDocument.py @@ -37,8 +37,7 @@ from NVDAObjects import NVDAObject from scriptHandler import script import api -import config -from config.configFlags import TetherTo +import eventHandler """Support for Microsoft Word via UI Automation.""" @@ -549,8 +548,8 @@ def event_textChange(self): # As Microsoft Word does not fire caret events when typing text, even though the caret does move. # Update braille also when tethered to review, and review position # if review follows caret. - braille.handler.handleCaretMove(self) - review.handleCaretMove(self) + 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 @@ -559,12 +558,14 @@ def event_UIA_notification(self, activityId=None, **kwargs): return super(WordDocument, self).event_UIA_notification(**kwargs) # Try to ensure that braille is updated when UIA is not used and - # ctrl-x or ctrl-z is pressed. - if config.conf["braille"]["tetherTo"] != TetherTo.REVIEW.value: - # Using getFocusObject because self does not work always. - braille.handler.handleCaretMove(api.getFocusObject()) - else: - braille.handler.handleReviewMove() + # ctrl-v, ctrl-x or ctrl-z is pressed. + # Using getFocusObject because self does not work always. + if ( + not UIAHandler.shouldUseUIAInMSWord(self.appModule) + and not eventHandler.isPendingEvents("caret", api.getFocusObject()) + ): + eventHandler.queueEvent("caret", api.getFocusObject()) + log.debug(f"{self.appModule.appName}: enqueued caret event") # The following overide of the EditableText._caretMoveBySentenceHelper private method # Falls back to the MS Word object model if available. diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 101ede312aa..3a4c6b79386 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -18,7 +18,7 @@ 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+x, control+z or backspace is pressed. +- 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) - From 02f94ed9cef68f2a185412d58e7e047cb7056a0d Mon Sep 17 00:00:00 2001 From: burmancomp Date: Tue, 26 Sep 2023 21:00:11 +0300 Subject: [PATCH 03/18] minor fix --- source/NVDAObjects/UIA/wordDocument.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/NVDAObjects/UIA/wordDocument.py b/source/NVDAObjects/UIA/wordDocument.py index b03c6d91b59..8dcea9361a1 100644 --- a/source/NVDAObjects/UIA/wordDocument.py +++ b/source/NVDAObjects/UIA/wordDocument.py @@ -548,7 +548,7 @@ def event_textChange(self): # As Microsoft Word does not fire caret events when typing text, even though the caret does move. # Update braille also when tethered to review, and review position # if review follows caret. - if not eventHandler.isPendingEvents("caret, self"): + if not eventHandler.isPendingEvents("caret", self): eventHandler.queueEvent("caret", self) def event_UIA_notification(self, activityId=None, **kwargs): From 3a96c9de56d2d23829d947aca3e8952dd7e498e7 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Tue, 26 Sep 2023 23:12:08 +0300 Subject: [PATCH 04/18] using helper scripts for paste, cut and undo --- source/NVDAObjects/IAccessible/winword.py | 21 +++++++++++++++++++++ source/NVDAObjects/UIA/wordDocument.py | 10 ---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 2df07a4bb33..224b4ae3e27 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -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): @@ -364,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() @@ -385,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", } diff --git a/source/NVDAObjects/UIA/wordDocument.py b/source/NVDAObjects/UIA/wordDocument.py index 8dcea9361a1..bc094d87fe2 100644 --- a/source/NVDAObjects/UIA/wordDocument.py +++ b/source/NVDAObjects/UIA/wordDocument.py @@ -36,7 +36,6 @@ ) from NVDAObjects import NVDAObject from scriptHandler import script -import api import eventHandler @@ -557,15 +556,6 @@ def event_UIA_notification(self, activityId=None, **kwargs): if activityId == "AccSN2": # Delete activity ID return super(WordDocument, self).event_UIA_notification(**kwargs) - # Try to ensure that braille is updated when UIA is not used and - # ctrl-v, ctrl-x or ctrl-z is pressed. - # Using getFocusObject because self does not work always. - if ( - not UIAHandler.shouldUseUIAInMSWord(self.appModule) - and not eventHandler.isPendingEvents("caret", api.getFocusObject()) - ): - eventHandler.queueEvent("caret", api.getFocusObject()) - log.debug(f"{self.appModule.appName}: enqueued caret event") # The following overide of the EditableText._caretMoveBySentenceHelper private method # Falls back to the MS Word object model if available. From 6aa015e0e523acffbee928fe2ef7eb343cf0ec8b Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 27 Sep 2023 07:03:28 +0300 Subject: [PATCH 05/18] some modifications --- source/NVDAObjects/IAccessible/winword.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 224b4ae3e27..0d9731dea11 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -23,9 +23,7 @@ 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): @@ -367,21 +365,13 @@ 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: + def script_updateBrailleAndReviewPosition(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()) + if not eventHandler.isPendingEvents("caret", self): + eventHandler.queueEvent("caret", self) 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() @@ -403,9 +393,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", + "kb:control+v": "updateBrailleAndReviewPosition", + "kb:control+x": "updateBrailleAndReviewPosition", + "kb:control+z": "updateBrailleAndReviewPosition", } From 8bc8c01403ce04ee72fdc8021625379ab6d1605a Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 27 Sep 2023 08:48:31 +0300 Subject: [PATCH 06/18] revert using api.getFocusObject --- source/NVDAObjects/IAccessible/winword.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 0d9731dea11..232dcde99b1 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -23,6 +23,7 @@ from ..behaviors import EditableTextWithoutAutoSelectDetection import NVDAObjects.window.winword as winWordWindowModule from speech import sayAll +import api import inputCore @@ -368,8 +369,9 @@ def script_previousParagraph(self,gesture): def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None: """Helper script to update braille and review position.""" gesture.send() - if not eventHandler.isPendingEvents("caret", self): - eventHandler.queueEvent("caret", self) + # 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") def focusOnActiveDocument(self, officeChartObject): From 2e4c5747e2bc07a23a1752c3a619f1436a1cb7b7 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 27 Sep 2023 15:49:59 +0300 Subject: [PATCH 07/18] suggested modifications --- source/NVDAObjects/IAccessible/winword.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 232dcde99b1..e35ef0955dc 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -17,6 +17,7 @@ import textInfos import eventHandler import scriptHandler +from scriptHandler import script import ui from . import IAccessible from displayModel import EditableTextDisplayModelTextInfo @@ -366,13 +367,13 @@ def script_previousParagraph(self,gesture): self._caretScriptPostMovedHelper(textInfos.UNIT_PARAGRAPH,gesture,None) script_previousParagraph.resumeSayAllMode = sayAll.CURSOR.CARET + @script(gestures=("kb:control+v", "kb:control+x", "kb:control+z")) def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None: """Helper script to update braille and review position.""" gesture.send() # 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") def focusOnActiveDocument(self, officeChartObject): rangeStart=officeChartObject.Parent.Range.Start @@ -395,9 +396,6 @@ def focusOnActiveDocument(self, officeChartObject): "kb:alt+pageUp":"caret_moveByCell", "kb:alt+pageDown":"caret_moveByCell", "kb:NVDA+alt+c":"reportCurrentComment", - "kb:control+v": "updateBrailleAndReviewPosition", - "kb:control+x": "updateBrailleAndReviewPosition", - "kb:control+z": "updateBrailleAndReviewPosition", } From 847ed528673a49604bd87ae569c82c776333e47b Mon Sep 17 00:00:00 2001 From: burmancomp Date: Fri, 29 Sep 2023 07:32:25 +0300 Subject: [PATCH 08/18] change log entry modification --- user_docs/en/changes.t2t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index d980288bcf9..4aad694a3b5 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -18,9 +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) +- Braille is updated when control+v, control+x, control+z or backspace is +pressed in MS Word when uia is not used. It is also updated when typing text, +and braille is tethered to review and review follows caret. (#3276) - == Changes for Developers == From 89ab7d8230e793edaa6ca96c8f7256a22d85780e Mon Sep 17 00:00:00 2001 From: burmancomp Date: Tue, 3 Oct 2023 12:47:36 +0300 Subject: [PATCH 09/18] refactored code to fix braille problem caused by modification of event_caret --- source/NVDAObjects/IAccessible/winword.py | 36 +++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index e35ef0955dc..69a701647f3 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -33,6 +33,9 @@ class WordDocument(IAccessible, EditableTextWithoutAutoSelectDetection, winWordW treeInterceptorClass = winWordWindowModule.WordDocumentTreeInterceptor shouldCreateTreeInterceptor=False TextInfo = winWordWindowModule.WordDocumentTextInfo + # Should braille and review position be updated, set to True in + # L{script_updateBrailleAndReviewPosition}. + _fromUpdateBrailleAndReviewPosition = False def _get_ignoreEditorRevisions(self): try: @@ -50,7 +53,17 @@ def _get_ignoreEditorRevisions(self): ignoreFormatting=False def event_caret(self): - self._lastSelectionPos = self.makeTextInfo(textInfos.POSITION_SELECTION) + curSelectionPos=self.makeTextInfo(textInfos.POSITION_SELECTION) + lastSelectionPos=getattr(self,'_lastSelectionPos',None) + self._lastSelectionPos=curSelectionPos + if lastSelectionPos: + if curSelectionPos._rangeObj.isEqual(lastSelectionPos._rangeObj): + log.debug("caret event before return") + if self._fromUpdateBrailleAndReviewPosition: + super().event_caret() + self._fromUpdateBrailleAndReviewPosition = False + return + log.debug("caret event") super(WordDocument,self).event_caret() def _get_role(self): @@ -367,11 +380,24 @@ def script_previousParagraph(self,gesture): self._caretScriptPostMovedHelper(textInfos.UNIT_PARAGRAPH,gesture,None) script_previousParagraph.resumeSayAllMode = sayAll.CURSOR.CARET - @script(gestures=("kb:control+v", "kb:control+x", "kb:control+z")) + @script(gestures=("kb:control+v", "kb:control+x", "kb:control+z", "kb:backspace")) def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None: - """Helper script to update braille and review position.""" - gesture.send() - # Using getFocusObject because self does not work always. + """Helper script to update braille and review position. + Caret event is not always fired when control+v, control+x or control+z is + pressed so enqueuing caret event for that. + When backspace is pressed and hold down, braille may not always be updated. + Allowing braille and review position updates in any cases when + this script is executed, seems to fix that problem. + """ + # Ensuring braille and review position updates are allowed in caret event. + self._fromUpdateBrailleAndReviewPosition = True + # Speech output when backspace is pressed. + if gesture._get_displayName() == "backspace": + scriptHandler.queueScript(self.script_caret_backspaceCharacter, gesture) + return + else: + gesture.send() + # Using getFocusObject because self may not always work. if not eventHandler.isPendingEvents("caret", api.getFocusObject()): eventHandler.queueEvent("caret", api.getFocusObject()) From 3f24e56364b9ea46d419ae4bca748d07cb62453c Mon Sep 17 00:00:00 2001 From: burmancomp Date: Thu, 5 Oct 2023 09:45:29 +0300 Subject: [PATCH 10/18] control+y, control+backspace, alt+backspace and minor modifications --- source/NVDAObjects/IAccessible/winword.py | 34 +++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 69a701647f3..8a430992886 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -52,18 +52,16 @@ def _get_ignoreEditorRevisions(self): #: True if formatting should be ignored (text only) such as for spellCheck error field ignoreFormatting=False - def event_caret(self): + def event_caret(self) -> None: curSelectionPos=self.makeTextInfo(textInfos.POSITION_SELECTION) lastSelectionPos=getattr(self,'_lastSelectionPos',None) self._lastSelectionPos=curSelectionPos if lastSelectionPos: if curSelectionPos._rangeObj.isEqual(lastSelectionPos._rangeObj): - log.debug("caret event before return") if self._fromUpdateBrailleAndReviewPosition: super().event_caret() self._fromUpdateBrailleAndReviewPosition = False return - log.debug("caret event") super(WordDocument,self).event_caret() def _get_role(self): @@ -380,26 +378,32 @@ def script_previousParagraph(self,gesture): self._caretScriptPostMovedHelper(textInfos.UNIT_PARAGRAPH,gesture,None) script_previousParagraph.resumeSayAllMode = sayAll.CURSOR.CARET - @script(gestures=("kb:control+v", "kb:control+x", "kb:control+z", "kb:backspace")) + @script( + gestures=( + "kb:control+v", "kb:control+x", "kb:control+y", "kb:control+z", + "kb:alt+backspace", "kb:backspace", "kb:control+backspace" + ) + ) def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None: """Helper script to update braille and review position. - Caret event is not always fired when control+v, control+x or control+z is - pressed so enqueuing caret event for that. - When backspace is pressed and hold down, braille may not always be updated. - Allowing braille and review position updates in any cases when - this script is executed, seems to fix that problem. + Caret event is not always fired when control+v, control+x, control+y + or control+z (alt+backspace) is pressed so enqueuing caret event for that. + When backspace or control+backspace is pressed and hold down, braille + may not always be updated. Allowing braille and review position updates + in L{event_caret} seems to fix that problem. """ # Ensuring braille and review position updates are allowed in caret event. self._fromUpdateBrailleAndReviewPosition = True - # Speech output when backspace is pressed. + # Speech output when backspace or control+backspace is pressed. if gesture._get_displayName() == "backspace": - scriptHandler.queueScript(self.script_caret_backspaceCharacter, gesture) - return + self.script_caret_backspaceCharacter(gesture) + elif gesture._get_displayName() == "ctrl+backspace": + self.script_caret_backspaceWord(gesture) else: gesture.send() - # Using getFocusObject because self may not always work. - if not eventHandler.isPendingEvents("caret", api.getFocusObject()): - eventHandler.queueEvent("caret", api.getFocusObject()) + # Using getFocusObject because self may not always work. + if not eventHandler.isPendingEvents("caret", api.getFocusObject()): + eventHandler.queueEvent("caret", api.getFocusObject()) def focusOnActiveDocument(self, officeChartObject): rangeStart=officeChartObject.Parent.Range.Start From 40b6e8a7ae4dcee2eb620083bac33b6e5bdef8e7 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Fri, 6 Oct 2023 15:04:07 +0300 Subject: [PATCH 11/18] minor modifications --- source/NVDAObjects/IAccessible/winword.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 8a430992886..a29719eaa0c 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -24,7 +24,6 @@ from ..behaviors import EditableTextWithoutAutoSelectDetection import NVDAObjects.window.winword as winWordWindowModule from speech import sayAll -import api import inputCore @@ -401,9 +400,8 @@ def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) self.script_caret_backspaceWord(gesture) else: gesture.send() - # Using getFocusObject because self may not always work. - if not eventHandler.isPendingEvents("caret", api.getFocusObject()): - eventHandler.queueEvent("caret", api.getFocusObject()) + if not eventHandler.isPendingEvents("caret", self): + eventHandler.queueEvent("caret", self) def focusOnActiveDocument(self, officeChartObject): rangeStart=officeChartObject.Parent.Range.Start From ca9c4dd369f9c0c25ea603a89659276813af5d0c Mon Sep 17 00:00:00 2001 From: burmancomp Date: Fri, 6 Oct 2023 21:15:27 +0300 Subject: [PATCH 12/18] retry From 357e88d207e11980ddc7a7c7fe86f8777d9b64cf Mon Sep 17 00:00:00 2001 From: burmancomp Date: Sat, 7 Oct 2023 14:01:02 +0300 Subject: [PATCH 13/18] updated changes entry --- user_docs/en/changes.t2t | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index f2dd63d48dd..30021550e9d 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -26,9 +26,10 @@ This option now announces additional relevant information about an object when t - The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271) - Multi line state is now correctly reported in applications using Java Access Bridge. (#14609) - In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436) -- Braille is updated when control+v, control+x, control+z or backspace is -pressed in MS Word when uia is not used. It is also updated when typing text, -and braille is tethered to review and review follows caret. (#3276) +- Braille is updated when control+v, control+x, control+y, control+z, +backspace or control+backspace is pressed in MS Word when uia is not used. +It is also updated with UIA, when typing text and braille is tethered to +review and review follows caret. (#3276) - == Changes for Developers == From 1af7bfe98e6fbb2ec0a1e91cfa0129104f3d4c8d Mon Sep 17 00:00:00 2001 From: burmancomp Date: Sat, 7 Oct 2023 14:43:47 +0300 Subject: [PATCH 14/18] suggested change --- source/NVDAObjects/IAccessible/winword.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index a29719eaa0c..e158b19fce4 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -400,8 +400,7 @@ def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) self.script_caret_backspaceWord(gesture) else: gesture.send() - if not eventHandler.isPendingEvents("caret", self): - eventHandler.queueEvent("caret", self) + self.event_caret() def focusOnActiveDocument(self, officeChartObject): rangeStart=officeChartObject.Parent.Range.Start From 31afc4986bc7b65ba74815b30edd5357a872215a Mon Sep 17 00:00:00 2001 From: burmancomp Date: Sat, 7 Oct 2023 17:36:09 +0300 Subject: [PATCH 15/18] minor modification of changes entry --- user_docs/en/changes.t2t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 30021550e9d..512b5b9684f 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -27,9 +27,9 @@ This option now announces additional relevant information about an object when t - Multi line state is now correctly reported in applications using Java Access Bridge. (#14609) - In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436) - Braille is updated when control+v, control+x, control+y, control+z, -backspace or control+backspace is pressed in MS Word when uia is not used. -It is also updated with UIA, when typing text and braille is tethered to -review and review follows caret. (#3276) +alt+backspace, backspace or control+backspace is pressed in MS Word when +UIA is not used. It is also updated with UIA, when typing text and braille +is tethered to review and review follows caret. (#3276) - == Changes for Developers == From 7cdefd14c3bd9767cf05bd8f8f92da4fbf7e907a Mon Sep 17 00:00:00 2001 From: burmancomp Date: Sun, 8 Oct 2023 11:46:04 +0300 Subject: [PATCH 16/18] code style/docstring/changes entry modifications --- source/NVDAObjects/IAccessible/winword.py | 13 +++++++++---- user_docs/en/changes.t2t | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index e158b19fce4..c7326bfc59d 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -379,17 +379,22 @@ def script_previousParagraph(self,gesture): @script( gestures=( - "kb:control+v", "kb:control+x", "kb:control+y", "kb:control+z", - "kb:alt+backspace", "kb:backspace", "kb:control+backspace" + "kb:control+v", + "kb:control+x", + "kb:control+y", + "kb:control+z", + "kb:alt+backspace", + "kb:backspace", + "kb:control+backspace", ) ) def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None: """Helper script to update braille and review position. Caret event is not always fired when control+v, control+x, control+y - or control+z (alt+backspace) is pressed so enqueuing caret event for that. + or control+z (alt+backspace) is pressed. When backspace or control+backspace is pressed and hold down, braille may not always be updated. Allowing braille and review position updates - in L{event_caret} seems to fix that problem. + in L{event_caret} should fix that problem. """ # Ensuring braille and review position updates are allowed in caret event. self._fromUpdateBrailleAndReviewPosition = True diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 512b5b9684f..fb3b5ef5cce 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -26,10 +26,10 @@ This option now announces additional relevant information about an object when t - The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271) - Multi line state is now correctly reported in applications using Java Access Bridge. (#14609) - In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436) -- Braille is updated when control+v, control+x, control+y, control+z, -alt+backspace, backspace or control+backspace is pressed in MS Word when -UIA is not used. It is also updated with UIA, when typing text and braille -is tethered to review and review follows caret. (#3276) +- Braille is updated when ``control+v``, ``control+x``, ``control+y``, +``control+z``, ``alt+backspace``, ``backspace`` or ``control+backspace`` +is pressed in MS Word when UIA is not used. It is also updated with UIA, when +typing text and braille is tethered to review and review follows caret. (#3276) - == Changes for Developers == From 31f27035b21d4bd590f5400fc98bca149f26c35f Mon Sep 17 00:00:00 2001 From: burmancomp Date: Mon, 9 Oct 2023 06:51:40 +0300 Subject: [PATCH 17/18] minor changes --- source/NVDAObjects/IAccessible/winword.py | 4 ++-- user_docs/en/changes.t2t | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index c7326bfc59d..5a0d1e82c6e 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -399,9 +399,9 @@ def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) # Ensuring braille and review position updates are allowed in caret event. self._fromUpdateBrailleAndReviewPosition = True # Speech output when backspace or control+backspace is pressed. - if gesture._get_displayName() == "backspace": + if gesture.displayName == "backspace": self.script_caret_backspaceCharacter(gesture) - elif gesture._get_displayName() == "ctrl+backspace": + elif gesture.displayName == "ctrl+backspace": self.script_caret_backspaceWord(gesture) else: gesture.send() diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index fb3b5ef5cce..91d721063b4 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -26,10 +26,8 @@ This option now announces additional relevant information about an object when t - The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271) - Multi line state is now correctly reported in applications using Java Access Bridge. (#14609) - In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436) -- Braille is updated when ``control+v``, ``control+x``, ``control+y``, -``control+z``, ``alt+backspace``, ``backspace`` or ``control+backspace`` -is pressed in MS Word when UIA is not used. It is also updated with UIA, when -typing text and braille is tethered to review and review follows caret. (#3276) +- In Microsoft Word with UIA disabled braille is updated when ``control+v``, ``control+x``, ``control+y``, ``control+z``, ``alt+backspace``, ``backspace`` or ``control+backspace`` is pressed. +It is also updated with UIA enabled, when typing text and braille is tethered to review and review follows caret. (#3276) - == Changes for Developers == From c56fed92d6d59129634670f0b64ab6e6098e60fc Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 18 Oct 2023 11:54:24 +0300 Subject: [PATCH 18/18] suggested code refactoring --- source/NVDAObjects/IAccessible/winword.py | 26 ++++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 5a0d1e82c6e..c3d57dcd436 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -384,28 +384,24 @@ def script_previousParagraph(self,gesture): "kb:control+y", "kb:control+z", "kb:alt+backspace", - "kb:backspace", - "kb:control+backspace", ) ) def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None: """Helper script to update braille and review position. - Caret event is not always fired when control+v, control+x, control+y - or control+z (alt+backspace) is pressed. - When backspace or control+backspace is pressed and hold down, braille - may not always be updated. Allowing braille and review position updates - in L{event_caret} should fix that problem. """ # Ensuring braille and review position updates are allowed in caret event. self._fromUpdateBrailleAndReviewPosition = True - # Speech output when backspace or control+backspace is pressed. - if gesture.displayName == "backspace": - self.script_caret_backspaceCharacter(gesture) - elif gesture.displayName == "ctrl+backspace": - self.script_caret_backspaceWord(gesture) - else: - gesture.send() - self.event_caret() + gesture.send() + # Caret event is not always fired when control+v, control+x, control+y + # or control+z (alt+backspace) is pressed. + self.event_caret() + + def _backspaceScriptHelper(self, unit: str, gesture: inputCore.InputGesture) -> None: + """Helper function to update braille and review position. + """ + # Ensuring braille and review position updates are allowed in caret event. + self._fromUpdateBrailleAndReviewPosition = True + super()._backspaceScriptHelper(unit, gesture) def focusOnActiveDocument(self, officeChartObject): rangeStart=officeChartObject.Parent.Range.Start