Repository: nvaccess/nvda

Issue:
NVDA says "unknown" for tree view items in some CHM files
### Steps to reproduce:
1. Install the latest alpha version of NVDA.
2. Open a CHM file from programs like JAWS or TortoiseSVN.
3. If the focus is not in the "Table of contents" tree view when you open the CHM file, move it there (e.g. with F6).
4. Use the arrow keys to navigate between the tree view items of the table of contents.
5. Observe how NVDA says "unknown" for each tree view item, instead of reading its name.

### Actual behavior:
NVDA says "unknown" for each tree view item, instead of reading its name.

### Expected behavior:
NVDA should read the item's name, as it does in v2020.3 and earlier versions.

### System configuration
- Operating system: Windows 10 Pro version 20H2 (build 19042.572), 64-bit, in Bulgarian with all locale settings set to "Bulgarian".
- NVDA version: alpha-21274,71c2c419, installed, in bulgarian.
- HTML Help: version 10.0.19041.561.
- Processor: Intel Core i5-9400F at 2.90GHz.
- RAM Memory: 16.00GB.
- Graphics: MSI GeForce GTX-1050TI Gaming X 4G, 4096MB dedicated memory, desktop resolution set to 1920x1080.
- Sound Card: Realtek ALC892 at Intel Cannon Point PCH.

### Other questions
#### Does the issue still occur after restarting your computer?
Yes, it does.

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
With NVDA 2020.3 the issue does not occur.

#### If addons are disabled, is your problem still occurring?
Yes, it does

#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
No, I haven't. But based on the fact that the issue does not occur with other/older versions of NVDA, the cause should not be in unregistered libraries.

### Notes:
"HTML Help" (hh.exe) is the application which apparently is the viewer for CHM files (or at least for some of them).



Discussion:
Just to exclude that the COM registration fixing tool improves this, could you still try to run it and see if it changes anything?

cc:@michaelDCurran

@Adriani90 I just run the COM registration fixing tool and restarted the computer after that just in case. But it did not help. I think the fix for SysListView64 is causing this, but I might be wrong.

Resolving patch:
diff --git a/source/NVDAObjects/IAccessible/sysTreeView32.py b/source/NVDAObjects/IAccessible/sysTreeView32.py
--- a/source/NVDAObjects/IAccessible/sysTreeView32.py
+++ b/source/NVDAObjects/IAccessible/sysTreeView32.py
@@ -1,8 +1,7 @@
-#NVDAObjects/IAccessible/sysTreeView32.py
-#A part of NonVisual Desktop Access (NVDA)
-#This file is covered by the GNU General Public License.
-#See the file COPYING for more details.
-#Copyright (C) 2007-2010 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net>
+# A part of NonVisual Desktop Access (NVDA)
+# This file is covered by the GNU General Public License.
+# See the file COPYING for more details.
+# Copyright (C) 2007-2020 NV Access Limited
 
 from ctypes import *
 from ctypes.wintypes import *
@@ -222,10 +221,10 @@ def initOverlayClass(self):
 			if parent and parent.hasFocus:
 				try:
 					kwargs = {}
-					UIA.kwargsFromSuper(kwargs, relation="focus")
+					UIA.kwargsFromSuper(kwargs, relation="focus", ignoreNonNativeElementsWithFocus=False)
 					self._uiaObj = UIA(**kwargs)
-				except:
-					log.debugWarning("Retrieving UIA focus failed", exc_info=True)
+				except Exception:
+					log.error("Retrieving UIA focus failed", exc_info=True)
 
 	def _get_role(self):
 		return self._uiaObj.role if self._uiaObj else controlTypes.ROLE_UNKNOWN
diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py
--- a/source/NVDAObjects/UIA/__init__.py
+++ b/source/NVDAObjects/UIA/__init__.py
@@ -993,7 +993,7 @@ def findOverlayClasses(self,clsList):
 						clsList.remove(x)
 
 	@classmethod
-	def kwargsFromSuper(cls,kwargs,relation=None):
+	def kwargsFromSuper(cls, kwargs, relation=None, ignoreNonNativeElementsWithFocus=True):
 		UIAElement=None
 		windowHandle=kwargs.get('windowHandle')
 		if isinstance(relation,tuple):
@@ -1016,7 +1016,7 @@ def kwargsFromSuper(cls,kwargs,relation=None):
 				log.debugWarning("getFocusedElement failed", exc_info=True)
 				return False
 			# Ignore this object if it is non native.
-			if not UIAHandler.handler.isNativeUIAElement(UIAElement):
+			if ignoreNonNativeElementsWithFocus and not UIAHandler.handler.isNativeUIAElement(UIAElement):
 				if UIAHandler._isDebug():
 					log.debug(
 						"kwargsFromSuper: ignoring non native element with focus"


Test patch: