Skip to content

Commit

Permalink
Merge branch 'master' into WinVersionClass
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsl committed Dec 7, 2020
2 parents 56c8a1a + f99644e commit 298dd3a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
3 changes: 0 additions & 3 deletions source/NVDAObjects/UIA/wordDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ def getTextWithFields(self,formatConfig=None):

class WordBrowseModeDocument(UIABrowseModeDocument):

def _get_isAlive(self):
return True

def shouldSetFocusToObj(self,obj):
# Ignore strange editable text fields surrounding most inner fields (links, table cells etc)
if obj.role==controlTypes.ROLE_EDITABLETEXT and obj.UIAElement.cachedAutomationID.startswith('UIA_AutomationId_Word_Content'):
Expand Down
2 changes: 1 addition & 1 deletion source/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def setFocusObject(obj):
try:
treeInterceptorObject=treeInterceptorHandler.update(o)
except:
log.exception("Error updating tree interceptor")
log.error("Error updating tree interceptor", exc_info=True)
#Always make sure that the focus object's treeInterceptor is forced to either the found treeInterceptor (if its in it) or to None
#This is to make sure that the treeInterceptor does not have to be looked up, which can cause problems for winInputHook
if obj is o or obj in treeInterceptorObject:
Expand Down
11 changes: 8 additions & 3 deletions source/appModules/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"ContentPresenter",
# Briefly shown when closing date calculation calendar.
"Light Dismiss",
# Unit conversion/convert from.
"Value1",
# Unit conversion/converts into.
"Value2",
]


Expand All @@ -49,9 +53,10 @@ def event_nameChange(self, obj, nextHandler):
obj.UIAAutomationId not in noCalculatorEntryAnnouncements
and obj.name != self._resultsCache
):
# For unit conversion, UIA notification event presents much better messages.
# For unit conversion, both name change and notification events are fired,
# although UIA notification event presents much better messages.
# For date calculation, live region change event is also fired for difference between dates.
if obj.UIAAutomationId not in ("Value1", "Value2", "DateDiffAllUnitsResultLabel"):
if obj.UIAAutomationId != "DateDiffAllUnitsResultLabel":
ui.message(obj.name)
self._resultsCache = obj.name
if not self._shouldAnnounceResult:
Expand Down Expand Up @@ -94,7 +99,7 @@ def script_calculatorResult(self, gesture):
# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.
# In redstone, pressing enter does not move focus to equals button.
if isinstance(focus, UIA):
if focus.UIAAutomationId == "CalculatorResults":
if focus.UIAAutomationId in ("CalculatorResults", "CalculatorAlwaysOnTopResults"):
queueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)
else:
resultsScreen = api.getForegroundObject().children[1].lastChild
Expand Down
20 changes: 15 additions & 5 deletions source/speech/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,21 @@ def _buildNextUtterance(self):
utterance.extend(seq)
lastSequenceIndexAddedToUtterance = seqIndex
# if any items are cancelled, cancel the whole utterance.
if utterance and not self._checkForCancellations(utterance):
log.error(f"Checking for cancellations failed, cancelling sequence: {utterance}")
try:
utteranceValid = len(utterance) == 0 or self._checkForCancellations(utterance)
except IndexError:
log.error(
f"Checking for cancellations failed, cancelling sequence: {utterance}",
exc_info=True
)
# Avoid infinite recursion by removing the problematic sequences:
del self._curPriQueue.pendingSequences[:lastSequenceIndexAddedToUtterance + 1]
utteranceValid = False

if utteranceValid:
return utterance
else:
return self._buildNextUtterance()
return utterance

def _checkForCancellations(self, utterance: SpeechSequence) -> bool:
"""
Expand All @@ -485,8 +494,9 @@ def _checkForCancellations(self, utterance: SpeechSequence) -> bool:
return True
utteranceIndex = self._getUtteranceIndex(utterance)
if utteranceIndex is None:
log.error("no utterance index, cant save cancellable commands")
return False
raise IndexError(
f"no utterance index({utteranceIndex}, cant save cancellable commands"
)
cancellableItems = list(
item for item in reversed(utterance) if isinstance(item, _CancellableSpeechCommand)
)
Expand Down

0 comments on commit 298dd3a

Please sign in to comment.