Commit d6917e0fd58b79f89e2328d73367dc9729fcf64e

Authored by Joanmarie Diggs
1 parent 90509f52

Automatically present details content upon expansion of controlling widget

src/orca/script_utilities.py
... ... @@ -451,6 +451,40 @@ class Utilities:
451 451 relation = filter(describedBy, relations)
452 452 return [r.getTarget(i) for r in relation for i in range(r.getNTargets())]
453 453  
  454 + def detailsContentForObject(self, obj):
  455 + details = self.detailsForObject(obj)
  456 + return list(map(self.displayedText, details))
  457 +
  458 + def detailsForObject(self, obj, textOnly=True):
  459 + """Return a list of objects containing details for obj."""
  460 +
  461 + try:
  462 + relations = obj.getRelationSet()
  463 + role = obj.getRole()
  464 + state = obj.getState()
  465 + except (LookupError, RuntimeError):
  466 + msg = 'ERROR: Exception getting relationset, role, and state for %s' % obj
  467 + debug.println(debug.LEVEL_INFO, msg, True)
  468 + return []
  469 +
  470 + if not state.contains(pyatspi.STATE_EXPANDED):
  471 + return []
  472 +
  473 + hasDetails = lambda x: x.getRelationType() == pyatspi.RELATION_DETAILS
  474 + relation = filter(hasDetails, relations)
  475 + details = [r.getTarget(i) for r in relation for i in range(r.getNTargets())]
  476 + if not details and role == pyatspi.ROLE_TOGGLE_BUTTON:
  477 + details = [child for child in obj]
  478 +
  479 + if not textOnly:
  480 + return details
  481 +
  482 + textObjects = []
  483 + for detail in details:
  484 + textObjects.extend(pyatspi.findAllDescendants(detail, self.queryNonEmptyText))
  485 +
  486 + return textObjects
  487 +
454 488 def displayedDescription(self, obj):
455 489 """Returns the text being displayed for the object describing obj."""
456 490  
... ...
src/orca/scripts/default.py
... ... @@ -2316,6 +2316,10 @@ class Script(script.Script):
2316 2316 speech.speak(self.speechGenerator.generateSpeech(obj, alreadyFocused=True))
2317 2317 self.pointOfReference['expandedChange'] = hash(obj), event.detail1
2318 2318  
  2319 + details = self.utilities.detailsContentForObject(obj)
  2320 + for detail in details:
  2321 + self.speakMessage(detail, interrupt=False)
  2322 +
2319 2323 def onIndeterminateChanged(self, event):
2320 2324 """Callback for object:state-changed:indeterminate accessibility events."""
2321 2325  
... ...