Skip to content

Commit

Permalink
Fix text paragraph navigation speech (nvaccess#16145)
Browse files Browse the repository at this point in the history
Closes nvaccess#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.
  • Loading branch information
mltony authored and Adriani90 committed Mar 13, 2024
1 parent 887122d commit aecdfa4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/browseMode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit aecdfa4

Please sign in to comment.