Skip to content

Commit 1fb6626

Browse files
authored
Merge 528d2ba into 64b6074
2 parents 64b6074 + 528d2ba commit 1fb6626

3 files changed

Lines changed: 43 additions & 35 deletions

File tree

source/NVDAObjects/UIA/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,11 +1228,14 @@ def findOverlayClasses(self,clsList):
12281228
if self.UIAIsWindowElement:
12291229
super(UIA,self).findOverlayClasses(clsList)
12301230
if self.UIATextPattern:
1231-
#Since there is a UIA text pattern, there is no need to use the win32 edit support at all
1231+
# Since there is a UIA text pattern, there is no need to use the win32 edit support at all.
1232+
# However, UIA classifies (rich) edit controls with a role of document and doesn't add a multiline state.
1233+
# Remove any win32 Edit class and insert EditBase to keep backwards compatibility with win32.
12321234
import NVDAObjects.window.edit
12331235
for x in list(clsList):
1234-
if issubclass(x,NVDAObjects.window.edit.Edit):
1236+
if issubclass(x, NVDAObjects.window.edit.Edit):
12351237
clsList.remove(x)
1238+
clsList.insert(0, NVDAObjects.window.edit.EditBase)
12361239

12371240
@classmethod
12381241
def kwargsFromSuper(cls, kwargs, relation=None, ignoreNonNativeElementsWithFocus=True):

source/NVDAObjects/window/edit.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2022 NV Access Limited, Babbage B.V., Cyrille Bougot
2+
# Copyright (C) 2006-2023 NV Access Limited, Babbage B.V., Cyrille Bougot, Leonard de Ruijter
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -75,18 +75,20 @@ class TextRangeStruct(ctypes.Structure):
7575
('lpstrText',ctypes.c_char_p),
7676
]
7777

78-
CFM_LINK=0x20
79-
CFE_AUTOBACKCOLOR=0x4000000
80-
CFE_AUTOCOLOR=0x40000000
81-
CFE_BOLD=1
82-
CFE_ITALIC=2
83-
CFE_UNDERLINE=4
84-
CFE_STRIKEOUT=8
85-
CFE_PROTECTED=16
86-
CFE_SUBSCRIPT=0x00010000 # Superscript and subscript are
87-
CFE_SUPERSCRIPT=0x00020000 # mutually exclusive
8878

89-
SCF_SELECTION=0x1
79+
CFM_LINK = 0x20
80+
CFE_AUTOBACKCOLOR = 0x4000000
81+
CFE_AUTOCOLOR = 0x40000000
82+
CFE_BOLD = 1
83+
CFE_ITALIC = 2
84+
CFE_UNDERLINE = 4
85+
CFE_STRIKEOUT = 8
86+
CFE_PROTECTED = 16
87+
CFE_SUBSCRIPT = 0x00010000 # Superscript and subscript are
88+
CFE_SUPERSCRIPT = 0x00020000 # mutually exclusive
89+
90+
SCF_SELECTION = 0x1
91+
9092

9193
class CharFormat2WStruct(ctypes.Structure):
9294
_fields_=[
@@ -176,7 +178,7 @@ def _getPointFromOffset(self,offset):
176178
res=watchdog.cancellableSendMessage(self.obj.windowHandle,winUser.EM_POSFROMCHAR,offset,None)
177179
point=locationHelper.Point(winUser.GET_X_LPARAM(res),winUser.GET_Y_LPARAM(res))
178180
# A returned coordinate can be a negative value if
179-
# the specified character is not displayed in the edit control's client area.
181+
# the specified character is not displayed in the edit control's client area.
180182
# If the specified index is greater than the index of the last character in the control,
181183
# the control returns -1.
182184
if point.x <0 or point.y <0:
@@ -289,7 +291,7 @@ def _getFormatFieldAndOffsets(self, offset, formatConfig, calculateOffsets=True)
289291
if charFormat is None: charFormat=self._getCharFormat(offset)
290292
formatField["link"]=bool(charFormat.dwEffects&CFM_LINK)
291293
return formatField,(startOffset,endOffset)
292-
294+
293295
def _setFormatFieldColor(
294296
self,
295297
charFormat: Union[CharFormat2AStruct, CharFormat2WStruct],
@@ -313,7 +315,7 @@ def _setFormatFieldColor(
313315
else:
314316
rgb = charFormat.crBackColor
315317
formatField["background-color"] = colors.RGB.fromCOLORREF(rgb)
316-
318+
317319
def _getSelectionOffsets(self):
318320
if self.obj.editAPIVersion>=1:
319321
charRange=CharRangeStruct()
@@ -602,7 +604,7 @@ def _setFormatFieldColor(
602604
formatField['background-color'] = _("Unknown color")
603605
else:
604606
formatField["background-color"] = colors.RGB.fromCOLORREF(bkColor)
605-
607+
606608
def _expandFormatRange(self, textRange, formatConfig):
607609
startLimit=self._rangeObj.start
608610
endLimit=self._rangeObj.end
@@ -640,7 +642,8 @@ def _getEmbeddedObjectLabel(self,embedRangeObj):
640642
pass
641643
if label:
642644
return label
643-
# Outlook 2003 and Outlook Express write the embedded object text to the display with GDI thus we can use display model
645+
# Outlook 2003 and Outlook Express write the embedded object text to the display with GDI
646+
# thus we can use display model
644647
left,top=embedRangeObj.GetPoint(comInterfaces.tom.tomStart)
645648
right,bottom=embedRangeObj.GetPoint(comInterfaces.tom.tomEnd|TA_BOTTOM)
646649
# Outlook Express bug: when expanding to the first embedded object on lines after the first, the range's start coordinates are the start coordinates of the previous character (on the line above)
@@ -836,7 +839,24 @@ def updateSelection(self):
836839
self.obj.ITextSelectionObject.start=self._rangeObj.start
837840
self.obj.ITextSelectionObject.end=self._rangeObj.end
838841

839-
class Edit(EditableTextWithAutoSelectDetection, Window):
842+
843+
class EditBase(Window):
844+
""""Base class for Edit and Rich Edit controls, shared by legacy and UIA implementations."""
845+
846+
def _get_value(self):
847+
return None
848+
849+
def _get_role(self):
850+
return controlTypes.Role.EDITABLETEXT
851+
852+
def _get_states(self):
853+
states = super()._get_states()
854+
if self.windowStyle & winUser.ES_MULTILINE:
855+
states.add(controlTypes.State.MULTILINE)
856+
return states
857+
858+
859+
class Edit(EditableTextWithAutoSelectDetection, EditBase):
840860

841861
editAPIVersion=0
842862
editValueUnit=textInfos.UNIT_LINE
@@ -866,12 +886,6 @@ def _get_ITextSelectionObject(self):
866886
self._ITextSelectionObject=None
867887
return self._ITextSelectionObject
868888

869-
def _get_value(self):
870-
return None
871-
872-
def _get_role(self):
873-
return controlTypes.Role.EDITABLETEXT
874-
875889
def event_caret(self):
876890
global selOffsetsAtLastCaretEvent
877891
#Fetching formatting and calculating word offsets needs to move the caret, so try to ignore these events
@@ -890,11 +904,6 @@ def event_caret(self):
890904
def event_valueChange(self):
891905
self.event_textChange()
892906

893-
def _get_states(self):
894-
states = super(Edit, self)._get_states()
895-
if self.windowStyle & winUser.ES_MULTILINE:
896-
states.add(controlTypes.State.MULTILINE)
897-
return states
898907

899908
class RichEdit(Edit):
900909
editAPIVersion=1

source/UIAHandler/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,9 @@
9090
"WuDuiListView",
9191
"ComboBox",
9292
"msctls_progress32",
93-
"Edit",
9493
"CommonPlacesWrapperWndClass",
9594
"SysMonthCal32",
9695
"SUPERGRID", # Outlook 2010 message list
97-
"RichEdit",
98-
"RichEdit20",
99-
"RICHEDIT50W",
10096
"SysListView32",
10197
"Button",
10298
# #8944: The Foxit UIA implementation is incomplete and should not be used for now.

0 commit comments

Comments
 (0)