Skip to content

Commit

Permalink
Implemented ui.message for error messages when a particular element t…
Browse files Browse the repository at this point in the history
…ype is not available on the page (nvaccess#588)
  • Loading branch information
Leonard de Ruijter committed Jun 28, 2016
1 parent 6f4df5f commit 1c342ae
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions source/browseMode.py
Expand Up @@ -284,7 +284,14 @@ def addQuickNav(cls, itemType, key, nextDoc, nextError, prevDoc, prevError, read
setattr(cls, funcName, script)
cls.__gestures["kb:shift+%s" % key] = scriptName

def script_elementsList(self,gesture, itemType=None):
def script_elementsList(self,gesture, itemType=None, errorMessage=None):
# First, check whether we have a preset itemType as well as whether elements of this type exist on the page
if itemType :
try:
next(self._iterNodesByType(itemType))
except StopIteration:
ui.message(errorMessage)
return
# We need this to be a modal dialog, but it mustn't block this script.
def run():
gui.mainFrame.prePopup()
Expand All @@ -301,11 +308,12 @@ def addElementsListQuickNav(cls, itemType, key, doc, error):
scriptSuffix = itemType[0].upper() + itemType[1:]
scriptName = "ElementsList%s" % scriptSuffix
funcName = "script_%s" % scriptName
script = lambda self,gesture: self.script_elementsList(gesture, itemType)
script = lambda self,gesture: self.script_elementsList(gesture, itemType, error)
script.__doc__ = doc
script.__name__ = funcName
setattr(cls, funcName, script)
cls.__gestures["kb:%s" % key] = scriptName
if key:
cls.__gestures["kb:%s" % key] = scriptName

def _activatePosition(self):
raise NotImplementedError
Expand Down

0 comments on commit 1c342ae

Please sign in to comment.