Skip to content

Commit

Permalink
In browse mode, you can now toggle single letter navigation on and of…
Browse files Browse the repository at this point in the history
…f by pressing NVDA+shift+space. When off, single letter keys are passed to the application, which is useful for some web applications such as Gmail, Twitter and Facebook.

Fixes #3203.
  • Loading branch information
michaelDCurran authored and jcsteh committed Jul 10, 2015
1 parent 7b7823c commit b7be7c2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
24 changes: 24 additions & 0 deletions source/browseMode.py
Expand Up @@ -176,6 +176,29 @@ def _get_shouldTrapNonCommandGestures(self):
def script_trapNonCommandGesture(self,gesture):
winsound.PlaySound("default",1)

singleLetterNavEnabled=True #: Whether single letter navigation scripts should be active (true) or if these letters should fall to the application.

def getAlternativeScript(self,gesture,script):
if self.passThrough or not gesture.isCharacter:
return script
if not self.singleLetterNavEnabled:
return None
if not script and self.shouldTrapNonCommandGestures:
script=self.script_trapNonCommandGesture
return script

def script_toggleSingleLetterNav(self,gesture):
if self.singleLetterNavEnabled:
self.singleLetterNavEnabled=False
# Translators: Reported when single letter navigation in browse mode is turned off.
ui.message(_("Single letter navigation off"))
else:
self.singleLetterNavEnabled=True
# Translators: Reported when single letter navigation in browse mode is turned on.
ui.message(_("Single letter navigation on"))
# Translators: the description for the toggleSingleLetterNavigation command in browse mode.
script_toggleSingleLetterNav.__doc__=_("Toggles single letter navigation on and off. When on, single letter keys in browse mode jump to various kinds of elements on the page. When off, these keys are passed to the application")

def _get_ElementsListDialog(self):
return ElementsListDialog

Expand Down Expand Up @@ -251,6 +274,7 @@ def script_activatePosition(self,gesture):
"kb:NVDA+f7": "elementsList",
"kb:enter": "activatePosition",
"kb:space": "activatePosition",
"kb:NVDA+shift+space":"toggleSingleLetterNav",
}

# Add quick navigation scripts.
Expand Down
5 changes: 3 additions & 2 deletions source/scriptHandler.py
Expand Up @@ -99,10 +99,11 @@ def findScript(gesture):
treeInterceptor = focus.treeInterceptor
if treeInterceptor and treeInterceptor.isReady:
func = _getObjScript(treeInterceptor, gesture, globalMapScripts)
from browseMode import BrowseModeTreeInterceptor
if isinstance(treeInterceptor,BrowseModeTreeInterceptor):
func=treeInterceptor.getAlternativeScript(gesture,func)
if func and (not treeInterceptor.passThrough or getattr(func,"ignoreTreeInterceptorPassThrough",False)):
return func
elif gesture.isCharacter and not treeInterceptor.passThrough and treeInterceptor.shouldTrapNonCommandGestures:
return treeInterceptor.script_trapNonCommandGesture

# NVDAObject level.
func = _getObjScript(focus, gesture, globalMapScripts)
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Expand Up @@ -10,6 +10,7 @@
- Many more unicode math symbols are now spoken when they appear in text. (#3805)
- Search suggestions in the Windows 10 start screen are automatically reported (#5049)
- Support for the EcoBraille 20, EcoBraille 40, EcoBraille 80 and EcoBraille Plus braille displays. (#4078)
- In browse mode, you can now toggle single letter navigation on and off by pressing NVDA+shift+space. When off, single letter keys are passed to the application, which is useful for some web applications such as Gmail, Twitter and Facebook. (#3203)


== Bug Fixes ==
Expand Down
6 changes: 6 additions & 0 deletions user_docs/en/userGuide.t2t
Expand Up @@ -503,6 +503,12 @@ To move to the beginning or end of containing elements such as lists and tables:
|| Name | Key | Description |
| Move to start of container | shift+comma | Moves to the start of the container (list, table, etc.) where the caret is positioned |
| Move past end of container | comma | Moves past the end of the container (list, table, etc.) where the caret is positioned |

%kc:endInclude
Some web applications such as Gmail, Twitter and Facebook use single letters as shortcut keys.
If you want to use these while still being able to use your cursor keys to read in browse mode, you can temporarily disable NVDA's single letter navigation keys.
%kc:beginInclude
To toggle single letter navigation on and off for the current document, press NVDA+shift+space.
%kc:endInclude

++ The Elements List ++
Expand Down

0 comments on commit b7be7c2

Please sign in to comment.