Skip to content

Commit

Permalink
Remove RTL and LTR marks from various places. Fix for nvaccess#8361
Browse files Browse the repository at this point in the history
Remove from clock name and value, read-only edit boxes in the properties window
Add an app module for dllhost, which is used to remove those characters from properties window on older Windows 10 builds.
  • Loading branch information
lukaszgo1 committed Aug 17, 2018
1 parent fabb3cd commit 40f82e6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
12 changes: 10 additions & 2 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,9 +1648,12 @@ def _get_isPresentableFocusAncestor(self):
self.isPresentableFocusAncestor = res = super(Groupbox, self).isPresentableFocusAncestor
return res

CHAR_LTR_MARK = u'\u200E'
CHAR_RTL_MARK = u'\u200F'
class TrayClockWClass(IAccessible):
"""
Based on NVDAObject but the role is changed to clock.
Depending on the version of Windows name or value contains left-to-right or right-to-left characters, so remove them from both.
"""

def _get_role(self):
Expand All @@ -1659,9 +1662,14 @@ def _get_role(self):
def _get_name(self):
# #4364 On some versions of Windows name contains redundant information that is available either in the role or the value, however on Windows 10 Anniversary Update and later the value is empty, so we cannot simply dismiss the name.
if super(TrayClockWClass, self).value is None:
return super(TrayClockWClass, self).name
return super(TrayClockWClass, self).name.replace(CHAR_LTR_MARK,'').replace(CHAR_RTL_MARK,'')
return None

def _get_value(self):
if super(TrayClockWClass, self).value is None:
return super(TrayClockWClass, self).value
return super(TrayClockWClass, self).value.replace(CHAR_LTR_MARK,'').replace(CHAR_RTL_MARK,'')

class OutlineItem(IAccessible):

def _get_value(self):
Expand Down Expand Up @@ -1838,7 +1846,7 @@ def event_alert(self):
(None,oleacc.ROLE_SYSTEM_ALERT):"Dialog",
(None,oleacc.ROLE_SYSTEM_PROPERTYPAGE):"Dialog",
(None,oleacc.ROLE_SYSTEM_GROUPING):"Groupbox",
("TrayClockWClass",oleacc.ROLE_SYSTEM_CLIENT):"TrayClockWClass",
("TrayClockWClass",oleacc.ROLE_SYSTEM_PUSHBUTTON):"TrayClockWClass",
("TrayClockWClass",oleacc.ROLE_SYSTEM_CLOCK):"TrayClockWClass",
("TRxRichEdit",oleacc.ROLE_SYSTEM_CLIENT):"delphi.TRxRichEdit",
(None,oleacc.ROLE_SYSTEM_OUTLINEITEM):"OutlineItem",
Expand Down
24 changes: 24 additions & 0 deletions source/appModules/dllhost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: UTF-8 -*-
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2018 NV Access Limited, Łukasz Golonka
# This file may be used under the terms of the GNU General Public License, version 2 or later.
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html

""" Under older builds of Windows 10 (from RTM release to Creators Update) dllhost is used to display a properties window.
Read-Only edit boxes in it can contain dates that include unwanted left-to-right and right-to-left indicator characters.
This simply imports a proper class from explorer app module, and maps it to a edit control.
"""

import appModuleHandler
from explorer import ReadOnlyEditBox

class AppModule(appModuleHandler.AppModule):

def chooseNVDAObjectOverlayClasses(self, obj, clsList):
windowClass = obj.windowClassName

if windowClass == "Edit":
clsList.insert(0, ReadOnlyEditBox)
return


12 changes: 12 additions & 0 deletions source/appModules/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ def _get_value(self):
return value
return value.replace(CHAR_LTR_MARK,'').replace(CHAR_RTL_MARK,'')

class ReadOnlyEditBox(IAccessible):
#Used for read-only edit boxes in a properties window.
#These can contain dates that include unwanted left-to-right and right-to-left indicator characters.

def _get_windowText(self):
if super(ReadOnlyEditBox, self).windowText is not None and controlTypes.STATE_READONLY in self.states:
return super(ReadOnlyEditBox, self).windowText.replace(CHAR_LTR_MARK,'').replace(CHAR_RTL_MARK,'')
return super(ReadOnlyEditBox, self).windowText

class AppModule(appModuleHandler.AppModule):

Expand Down Expand Up @@ -208,6 +216,10 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
toolbarParent = None
if toolbarParent and toolbarParent.windowClassName == "SysPager":
clsList.insert(0, NotificationArea)
return

if windowClass == "Edit":
clsList.insert(0, ReadOnlyEditBox)
return # Optimization: return early to avoid comparing class names and roles that will never match.

if windowClass == "SysListView32" and role == controlTypes.ROLE_MENUITEM:
Expand Down

0 comments on commit 40f82e6

Please sign in to comment.