From aecdfa445803766aa8e6864a9d64fee1f324e651 Mon Sep 17 00:00:00 2001 From: mltony <34804124+mltony@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:20:54 -0800 Subject: [PATCH] Fix text paragraph navigation speech (#16145) Closes #16143 Summary of the issue: NVDA reports roles incorrectly when navigating using P quickNav Description of user facing changes Fixed speech so that p quickNav command behaves as expected. Description of development approach A quick investigation shows that this is the behavior of speech.speakTextInfo(info, reason=OutputReason.QUICKNAV) as called in browseMode.py:216. I didn't change that in textNav PR. This makes sense for other QuickNav commands. For example on that page if you press B, you get: Open global navigation menu Button Note that the word button goes in the end. If you stumble upon the same button via Control+Up/Down then the speech is Button Open global navigation menu So since text paragraph navigation is more similar to caret navigation in the sense that it navigates to text that might contain different roles, I propose to change to reason=OutputReason.CARET for text paragraph navigation as it seems to fix this issue. --- source/browseMode.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/browseMode.py b/source/browseMode.py index cd3a0aeae69..9397b5dd7fe 100644 --- a/source/browseMode.py +++ b/source/browseMode.py @@ -175,13 +175,20 @@ def isRenameAllowed(self): class TextInfoQuickNavItem(QuickNavItem): """ Represents a quick nav item in a browse mode document who's positions are represented by a L{textInfos.TextInfo}. """ - def __init__(self,itemType,document,textInfo): + def __init__( + self, + itemType: str, + document: treeInterceptorHandler.TreeInterceptor, + textInfo: textInfos.TextInfo, + outputReason: OutputReason = OutputReason.QUICKNAV, + ): """ See L{QuickNavItem.__init__} for itemType and document argument definitions. @param textInfo: the textInfo position this item represents. @type textInfo: L{textInfos.TextInfo} """ self.textInfo=textInfo + self.outputReason = outputReason super(TextInfoQuickNavItem,self).__init__(itemType,document) def __lt__(self,other): @@ -213,7 +220,7 @@ def report(self,readUnit=None): if info.compareEndPoints(fieldInfo, "endToEnd") > 0: # We've expanded past the end of the field, so limit to the end of the field. info.setEndPoint(fieldInfo, "endToEnd") - speech.speakTextInfo(info, reason=OutputReason.QUICKNAV) + speech.speakTextInfo(info, reason=self.outputReason) def activate(self): self.textInfo.obj._activatePosition(info=self.textInfo) @@ -471,7 +478,7 @@ def _iterSimilarParagraph( return value = paragraphFunction(info) if value == desiredValue: - yield TextInfoQuickNavItem(kind, self, info.copy()) + yield TextInfoQuickNavItem(kind, self, info.copy(), outputReason=OutputReason.CARET) def _quickNavScript(self,gesture, itemType, direction, errorMessage, readUnit):