Fix some interruption issues in discord.

This commit is contained in:
2026-05-15 13:46:34 -07:00
parent 0acba6a733
commit 4145e9375b
2 changed files with 142 additions and 2 deletions
+44 -2
View File
@@ -1083,7 +1083,7 @@ class Script(default.Script):
"""Speaks the specified contents."""
utterances = self.speechGenerator.generateContents(contents, **args)
speech.speak(utterances)
speech.speak(utterances, interrupt=args.get("interrupt", True))
def sayCharacter(self, obj):
"""Speaks the character at the current caret position."""
@@ -1874,11 +1874,15 @@ class Script(default.Script):
debug.printMessage(debug.LEVEL_INFO, msg, True)
return True
if self.utilities.shouldInterruptForLocusOfFocusChange(oldFocus, newFocus, event):
self.presentationInterrupt()
args["interrupt"] = False
if contents:
self.speakContents(contents, **args)
else:
utterances = self.speechGenerator.generateSpeech(newFocus, **args)
speech.speak(utterances)
speech.speak(utterances, interrupt=False)
self._saveFocusedObjectInfo(newFocus)
@@ -2650,6 +2654,44 @@ class Script(default.Script):
self._lastCommandWasMouseButton = True
return False
def onDescriptionChanged(self, event):
"""Callback for object:property-change:accessible-description events."""
if self.utilities.eventIsBrowserUINoise(event):
msg = "WEB: Ignoring event believed to be browser UI noise"
debug.printMessage(debug.LEVEL_INFO, msg, True)
return True
obj = event.source
if not self.utilities.inDocumentContent(obj):
return False
descriptions = self.pointOfReference.get('descriptions', {})
oldDescription = descriptions.get(hash(obj))
if oldDescription == event.any_data:
tokens = ["WEB: Old description (", oldDescription, ") is the same as new one"]
debug.printTokens(debug.LEVEL_INFO, tokens, True)
return True
descriptions[hash(obj)] = event.any_data
self.pointOfReference['descriptions'] = descriptions
if obj != cthulhu_state.locusOfFocus:
msg = "WEB: Description change is for object other than locusOfFocus"
debug.printMessage(debug.LEVEL_INFO, msg, True)
return True
if not event.any_data:
return True
name = AXObject.get_name(obj)
if self.utilities.stringsAreRedundant(name, event.any_data):
tokens = ["WEB: Description change is redundant with name for", obj]
debug.printTokens(debug.LEVEL_INFO, tokens, True)
return True
self.presentMessage(event.any_data, interrupt=False)
return True
def onNameChanged(self, event):
"""Callback for object:property-change:accessible-name events."""