Skip to content

Commit

Permalink
NVDA 2021.1 change: Fix misleading log message for aria-current="true"
Browse files Browse the repository at this point in the history
  • Loading branch information
AAClause committed Feb 7, 2021
1 parent 818064f commit 95ff2c2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
8 changes: 8 additions & 0 deletions addon/globalPlugins/brailleExtender/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
import os

import addonHandler
import controlTypes
import globalVars
import languageHandler

def get_is_current_no():
if hasattr(controlTypes, "IsCurrent"):
return controlTypes.IsCurrent.NO
return False

IS_CURRENT_NO = get_is_current_no()

configDir = "%s/brailleExtender" % globalVars.appArgs.configPath
baseDir = os.path.dirname(__file__)
addonDir = os.path.join(baseDir, "..", "..")
Expand Down
25 changes: 16 additions & 9 deletions addon/globalPlugins/brailleExtender/objectpresentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from logHandler import log

from . import addoncfg
from .common import N_, CHOICE_liblouis, CHOICE_none, ADDON_ORDER_PROPERTIES
from .common import N_, CHOICE_liblouis, CHOICE_none, ADDON_ORDER_PROPERTIES, IS_CURRENT_NO
from .documentformatting import CHOICES_LABELS, get_report
from .utils import get_output_reason

Expand Down Expand Up @@ -149,6 +149,18 @@ def update_NVDAObjectRegion(self):
super(braille.NVDAObjectRegion, self).update()


def is_current_display_string(current):
if hasattr(current, "displayString"):
return current.displayString
if hasattr(controlTypes, "isCurrentLabels"):
try:
return controlTypes.isCurrentLabels[current]
except KeyError:
pass
log.debugWarning("Aria-current value not handled: %s" % current)
return ''


def getPropertiesBraille(**propertyValues) -> str:
properties = {}
positiveStateLabels = braille.positiveStateLabels
Expand Down Expand Up @@ -278,14 +290,9 @@ def getPropertiesBraille(**propertyValues) -> str:
cellCoordsText = rowCoordinate
elif columnCoordinate:
cellCoordsText = columnHeaderText
current = propertyValues.get("current", False)
if current:
try:
currentStr = controlTypes.isCurrentLabels[current]
except KeyError:
log.debugWarning("Aria-current value not handled: %s" % current)
currentStr = controlTypes.isCurrentLabels[True]
properties["current"] = currentStr
isCurrent = propertyValues.get("current", IS_CURRENT_NO)
if isCurrent != IS_CURRENT_NO:
properties["current"] = is_current_display_string(isCurrent)
placeholder = propertyValues.get("placeholder", None)
if placeholder:
properties["placeholder"] = placeholder
Expand Down
2 changes: 1 addition & 1 deletion addon/globalPlugins/brailleExtender/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig):
states = field.get("states", set())
value = field.get('value', None)
childControlCount = int(field.get('_childcontrolcount',"0"))
current = field.get('current', None)
current = field.get("current", IS_CURRENT_NO)
placeholder = field.get('placeholder', None)
roleText = field.get('roleTextBraille', field.get('roleText'))
roleTextPost = None
Expand Down
2 changes: 1 addition & 1 deletion addon/globalPlugins/brailleExtender/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
addonHandler.initTranslation()
import treeInterceptorHandler
import unicodedata
from .addoncfg import CHOICE_braille,CHOICE_speech , CHOICE_speechAndBraille
from .addoncfg import CHOICE_braille, CHOICE_speech, CHOICE_speechAndBraille
from .common import INSERT_AFTER, INSERT_BEFORE, REPLACE_TEXT, baseDir
from . import huc
from . import tabledictionaries
Expand Down

0 comments on commit 95ff2c2

Please sign in to comment.