From 2fadd84437a3eb16e9eac75f4ddea26fcbe8a70f Mon Sep 17 00:00:00 2001 From: mltony Date: Sat, 23 Apr 2022 13:48:35 -0700 Subject: [PATCH] Compatibility with v2022 --- addon/globalPlugins/browserNav/quickJump.py | 8 +- addon/globalPlugins/browserNav/utils.py | 159 +++++++++++++++++++- 2 files changed, 163 insertions(+), 4 deletions(-) diff --git a/addon/globalPlugins/browserNav/quickJump.py b/addon/globalPlugins/browserNav/quickJump.py index c0dcd33..af872f9 100644 --- a/addon/globalPlugins/browserNav/quickJump.py +++ b/addon/globalPlugins/browserNav/quickJump.py @@ -187,7 +187,11 @@ def __init__( object.__setattr__(self, 'attribute', ParagraphAttribute(d['attribute'])) value = d['value'] if self.attribute == ParagraphAttribute.ROLE: - value = controlTypes.Role(value) + try: + textValue = utils.NVDA2021Role(value).name + except ValueError: + textValue = value + value = getattr(controlTypes.Role, textValue) object.__setattr__(self, 'value', value) elif userString is not None: s = userString.strip() @@ -217,7 +221,7 @@ def __init__( def asDict(self): return { 'attribute': self.attribute.value, - 'value': self.value.value if self.attribute == ParagraphAttribute.ROLE else self.value, + 'value': self.value.name if self.attribute == ParagraphAttribute.ROLE else self.value, } diff --git a/addon/globalPlugins/browserNav/utils.py b/addon/globalPlugins/browserNav/utils.py index 239a740..cfc800e 100644 --- a/addon/globalPlugins/browserNav/utils.py +++ b/addon/globalPlugins/browserNav/utils.py @@ -7,6 +7,7 @@ import controlTypes import core import _ctypes +from enum import Enum import IAccessibleHandler from queue import Queue import threading @@ -205,5 +206,159 @@ def getGeckoParagraphIndent(textInfo, documentHolder=None, oneLastAttempt=False) return getGeckoParagraphIndent(textInfo, documentHolder, oneLastAttempt=True) return None -# For quick finding paragraphs, llok at: -# VirtualBufferTextInfo._getParagraphOffsets \ No newline at end of file +# For quick finding paragraphs, look at: +# VirtualBufferTextInfo._getParagraphOffsets + +# Role constants changed in NVDA v2022 so we need to decode the old values. +class NVDA2021Role(Enum): + UNKNOWN = 0 + WINDOW = 1 + TITLEBAR = 2 + PANE = 3 + DIALOG = 4 + CHECKBOX = 5 + RADIOBUTTON = 6 + STATICTEXT = 7 + EDITABLETEXT = 8 + BUTTON = 9 + MENUBAR = 10 + MENUITEM = 11 + POPUPMENU = 12 + COMBOBOX = 13 + LIST = 14 + LISTITEM = 15 + GRAPHIC = 16 + HELPBALLOON = 17 + TOOLTIP = 18 + LINK = 19 + TREEVIEW = 20 + TREEVIEWITEM = 21 + TAB = 22 + TABCONTROL = 23 + SLIDER = 24 + PROGRESSBAR = 25 + SCROLLBAR = 26 + STATUSBAR = 27 + TABLE = 28 + TABLECELL = 29 + TABLECOLUMN = 30 + TABLEROW = 31 + TABLECOLUMNHEADER = 32 + TABLEROWHEADER = 33 + FRAME = 34 + TOOLBAR = 35 + DROPDOWNBUTTON = 36 + CLOCK = 37 + SEPARATOR = 38 + FORM = 39 + HEADING = 40 + HEADING1 = 41 + HEADING2 = 42 + HEADING3 = 43 + HEADING4 = 44 + HEADING5 = 45 + HEADING6 = 46 + PARAGRAPH = 47 + BLOCKQUOTE = 48 + TABLEHEADER = 49 + TABLEBODY = 50 + TABLEFOOTER = 51 + DOCUMENT = 52 + ANIMATION = 53 + APPLICATION = 54 + BOX = 55 + GROUPING = 56 + PROPERTYPAGE = 57 + CANVAS = 58 + CAPTION = 59 + CHECKMENUITEM = 60 + DATEEDITOR = 61 + ICON = 62 + DIRECTORYPANE = 63 + EMBEDDEDOBJECT = 64 + ENDNOTE = 65 + FOOTER = 66 + FOOTNOTE = 67 + GLASSPANE = 69 + HEADER = 70 + IMAGEMAP = 71 + INPUTWINDOW = 72 + LABEL = 73 + NOTE = 74 + PAGE = 75 + RADIOMENUITEM = 76 + LAYEREDPANE = 77 + REDUNDANTOBJECT = 78 + ROOTPANE = 79 + EDITBAR = 80 + TERMINAL = 82 + RICHEDIT = 83 + RULER = 84 + SCROLLPANE = 85 + SECTION = 86 + SHAPE = 87 + SPLITPANE = 88 + VIEWPORT = 89 + TEAROFFMENU = 90 + TEXTFRAME = 91 + TOGGLEBUTTON = 92 + BORDER = 93 + CARET = 94 + CHARACTER = 95 + CHART = 96 + CURSOR = 97 + DIAGRAM = 98 + DIAL = 99 + DROPLIST = 100 + SPLITBUTTON = 101 + MENUBUTTON = 102 + DROPDOWNBUTTONGRID = 103 + MATH = 104 + GRIP = 105 + HOTKEYFIELD = 106 + INDICATOR = 107 + SPINBUTTON = 108 + SOUND = 109 + WHITESPACE = 110 + TREEVIEWBUTTON = 111 + IPADDRESS = 112 + DESKTOPICON = 113 + INTERNALFRAME = 115 + DESKTOPPANE = 116 + OPTIONPANE = 117 + COLORCHOOSER = 118 + FILECHOOSER = 119 + FILLER = 120 + MENU = 121 + PANEL = 122 + PASSWORDEDIT = 123 + FONTCHOOSER = 124 + LINE = 125 + FONTNAME = 126 + FONTSIZE = 127 + BOLD = 128 + ITALIC = 129 + UNDERLINE = 130 + FGCOLOR = 131 + BGCOLOR = 132 + SUPERSCRIPT = 133 + SUBSCRIPT = 134 + STYLE = 135 + INDENT = 136 + ALIGNMENT = 137 + ALERT = 138 + DATAGRID = 139 + DATAITEM = 140 + HEADERITEM = 141 + THUMB = 142 + CALENDAR = 143 + VIDEO = 144 + AUDIO = 145 + CHARTELEMENT = 146 + DELETED_CONTENT = 147 + INSERTED_CONTENT = 148 + LANDMARK = 149 + ARTICLE = 150 + REGION = 151 + FIGURE = 152 + MARKED_CONTENT = 153