|
29 | 29 | import globalPluginHandler |
30 | 30 | import brailleInput |
31 | 31 | import locationHelper |
| 32 | +import aria |
32 | 33 |
|
33 | 34 | class NVDAObjectTextInfo(textInfos.offsets.OffsetsTextInfo): |
34 | 35 | """A default TextInfo which is used to enable text review of information about widgets that don't support text content. |
@@ -407,8 +408,20 @@ def _get_roleText(self): |
407 | 408 | No string is provided by default, meaning that NVDA will fall back to using role. |
408 | 409 | Examples of where this property might be overridden are shapes in Powerpoint, or ARIA role descriptions. |
409 | 410 | """ |
| 411 | + if self.landmark and self.landmark in aria.landmarkRoles: |
| 412 | + return f"{aria.landmarkRoles[self.landmark]} {controlTypes.roleLabels[controlTypes.ROLE_LANDMARK]}" |
410 | 413 | return None |
411 | 414 |
|
| 415 | + def _get_roleTextBraille(self): |
| 416 | + """ |
| 417 | + A custom role string for this object, which is used for braille presentation, |
| 418 | + which will override the standard label for this object's role property as well as the value of roleText. |
| 419 | + By default, NVDA falls back to using roleText. |
| 420 | + """ |
| 421 | + if self.landmark and self.landmark in braille.landmarkLabels: |
| 422 | + return f"{braille.roleLabels[controlTypes.ROLE_LANDMARK]} {braille.landmarkLabels[self.landmark]}" |
| 423 | + return self.roleText |
| 424 | + |
412 | 425 | def _get_value(self): |
413 | 426 | """The value of this object (example: the current percentage of a scrollbar, the selected option in a combo box). |
414 | 427 | @rtype: str |
@@ -710,14 +723,39 @@ def _get_presentationType(self): |
710 | 723 | states=self.states |
711 | 724 | if controlTypes.STATE_INVISIBLE in states or controlTypes.STATE_UNAVAILABLE in states: |
712 | 725 | return self.presType_unavailable |
713 | | - role=self.role |
| 726 | + role = self.role |
| 727 | + landmark = self.landmark |
| 728 | + if ( |
| 729 | + role == controlTypes.ROLE_LANDMARK |
| 730 | + or landmark |
| 731 | + ) and not config.conf["documentFormatting"]["reportLandmarks"]: |
| 732 | + return self.presType_layout |
| 733 | + |
| 734 | + roleText = self.roleText |
| 735 | + if roleText: |
| 736 | + # If roleText is set, the object is very likely to communicate something relevant to the user. |
| 737 | + return self.presType_content |
714 | 738 |
|
715 | 739 | #Static text should be content only if it really use usable text |
716 | 740 | if role==controlTypes.ROLE_STATICTEXT: |
717 | 741 | text=self.makeTextInfo(textInfos.POSITION_ALL).text |
718 | 742 | return self.presType_content if text and not text.isspace() else self.presType_layout |
719 | 743 |
|
720 | | - if role in (controlTypes.ROLE_UNKNOWN, controlTypes.ROLE_PANE, controlTypes.ROLE_TEXTFRAME, controlTypes.ROLE_ROOTPANE, controlTypes.ROLE_LAYEREDPANE, controlTypes.ROLE_SCROLLPANE, controlTypes.ROLE_SPLITPANE, controlTypes.ROLE_SECTION, controlTypes.ROLE_PARAGRAPH, controlTypes.ROLE_TITLEBAR, controlTypes.ROLE_LABEL, controlTypes.ROLE_WHITESPACE,controlTypes.ROLE_BORDER): |
| 744 | + if role in ( |
| 745 | + controlTypes.ROLE_UNKNOWN, |
| 746 | + controlTypes.ROLE_PANE, |
| 747 | + controlTypes.ROLE_TEXTFRAME, |
| 748 | + controlTypes.ROLE_ROOTPANE, |
| 749 | + controlTypes.ROLE_LAYEREDPANE, |
| 750 | + controlTypes.ROLE_SCROLLPANE, |
| 751 | + controlTypes.ROLE_SPLITPANE, |
| 752 | + controlTypes.ROLE_SECTION, |
| 753 | + controlTypes.ROLE_PARAGRAPH, |
| 754 | + controlTypes.ROLE_TITLEBAR, |
| 755 | + controlTypes.ROLE_LABEL, |
| 756 | + controlTypes.ROLE_WHITESPACE, |
| 757 | + controlTypes.ROLE_BORDER |
| 758 | + ): |
721 | 759 | return self.presType_layout |
722 | 760 | name = self.name |
723 | 761 | description = self.description |
@@ -1164,6 +1202,11 @@ def _get_devInfo(self): |
1164 | 1202 | except Exception as e: |
1165 | 1203 | ret = "exception: %s" % e |
1166 | 1204 | info.append("role: %s" % ret) |
| 1205 | + try: |
| 1206 | + ret = repr(self.roleText) |
| 1207 | + except Exception as e: |
| 1208 | + ret = f"exception: {e}" |
| 1209 | + info.append(f"roleText: {ret}") |
1167 | 1210 | try: |
1168 | 1211 | stateConsts = dict((const, name) for name, const in controlTypes.__dict__.items() if name.startswith("STATE_")) |
1169 | 1212 | ret = ", ".join( |
|
0 commit comments