Skip to content

Commit

Permalink
Fix up from #12210: Excel without UIA enabled: again allow typing and…
Browse files Browse the repository at this point in the history
… editing in cells (#12321)

Fixes #12303

After merging of pr #12210 editing cells in Excel without UIA enabled became im possible as NVDA did not report / track focus had ented the Cell Edit control.
This was due to the EXCEL6 window accidentally being marked as having a good UIA implementation. This was testing code left over from the early implementation of #12210.

Description of how this pull request fixes the issue:
Remove EXCEL6 from the good UIA windows list.
Also ensure that MSAA focus events on this window are ignored when using Excel with UIA enabled, as Excel will fire its own UIA focus event on an edit control within the active cell.
  • Loading branch information
michaelDCurran authored Apr 22, 2021
1 parent a94f5fe commit 03746a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion source/_UIAHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
goodUIAWindowClassNames=[
# A WDAG (Windows Defender Application Guard) Window is always native UIA, even if it doesn't report as such.
'RAIL_WINDOW',
"EXCEL6",
]

badUIAWindowClassNames=[
Expand Down
26 changes: 25 additions & 1 deletion source/appModules/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html

import time
import config
import eventHandler
import api
import UIAHandler
Expand All @@ -15,6 +16,8 @@
from NVDAObjects.window.edit import UnidentifiedEdit
from NVDAObjects.window import Window
from NVDAObjects.window.excel import ExcelCell
from NVDAObjects.IAccessible import IAccessible


class Excel6(Window):
"""
Expand Down Expand Up @@ -43,6 +46,17 @@ def _get_focusRedirect(self):
self.focusRedirect=obj
return obj


class Excel6_WhenUIAEnabled(IAccessible):
"""
#12303: When accessing Microsoft Excel via UI Automation
MSAA focus events on the old formula edit window should be completely ignored.
UI Automation will fire its own ones.
"""

shouldAllowIAccessibleFocusEvent = False


class AppModule(appModuleHandler.AppModule):

def chooseNVDAObjectOverlayClasses(self, obj, clsList):
Expand All @@ -55,4 +69,14 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
pass
clsList.insert(0, DisplayModelEditableText)
if windowClass=="EXCEL6":
clsList.insert(0,Excel6)
if config.conf["UIA"]["useInMSExcelWhenAvailable"]:
# #12303: When accessing Microsoft Excel via UI Automation
# MSAA focus events on the old formula edit window should be completely ignored.
# UI Automation will fire its own ones.
clsList.insert(0, Excel6_WhenUIAEnabled)
else:
# #12303: The old Formula Edit window in recent versions of Excel
# may not be accessible with display models as GDI is no longer used.
# However, UI Automation does expose an accessible edit control within the active cell,
# So use a class that will redirect focus to that.
clsList.insert(0, Excel6)

0 comments on commit 03746a1

Please sign in to comment.