Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support in-cell editing in Excel 2016/365 #9290

Merged
merged 6 commits into from
Feb 19, 2019
Merged

Support in-cell editing in Excel 2016/365 #9290

merged 6 commits into from
Feb 19, 2019

Conversation

michaelDCurran
Copy link
Member

Link to issue number:

Fixes #8146

Summary of the issue:

In Excel 2010 and below, NVDA would use its displayModel code to interact with the formula / cell edit control.
Excel 2013 introduced UI Automation support for the edit control.
However, in Excel 2016/365 it seems that the UI Automation element for the in-cell edit control is a child of the active cell, and therefore uses the window handle for the sheet, rather than the specific EXCEL6 in-cell edit window.
But because we ignore UI Automation in the EXCEL7 (sheet) window, all we get now is a generic MSAA client object in the EXCEL6 window with focus. In short, NVDA just says "unknown" and the edit control is not usable.
Turning off in-cell editing in Excel's options allows NVDA to interact with the edit control properly as the window handle for the edit control will be "EXCEL<" not "EXCEL7". But this is just a work-around and many users do not know to do this.

Description of how this pull request fixes the issue:

Provide an EXCEL6 NVDAObject overlay class in the Excel appModule, which if inaccessible redirects focus to the UIA element for the in-cell edit control if available.

Testing performed:

In a sheet with in-cell editing turned on: pressed f2 and confirmed that NVDA announced the edit control and that the arrow keys allowed navigating the text.
Then with in-cell editing turned off, pressed f2 and confirmed that NVDA still announced the edit control and that the arrow keys could navigate the edit control.
Performed the above 2 tests but this time rather than pressing f2, simply started typing in the cell.
Testing on Excel 2010 is still required.

Known issues with pull request:

None.

Change log entry:

Bug fixes:

@michaelDCurran
Copy link
Member Author

Here is a try build: https://ci.appveyor.com/api/buildjobs/gm6vehptupg96r26/artifacts/output%2Fnvda_snapshot_try-i8146-16783%2Cb124149d.exe
Although I have confirmed that in-cell editing now works in Excel 2016/365, Could I please ask @Qchristensen or someone to test this with Excel 2010 and ensure that editing cells still works there?

@nishimotz
Copy link
Contributor

I have just confirmed that the try build 16783 resolves an issue reported from Japanese users:

  • open Home tab / Conditional Formatting / Manage Rule / New Rule
  • select "Use a formula to determine which cells to format" and press Tab
  • at the "Formula" edit, press F2 to make sure caret moves inside the edit
  • with NVDA 2018.4.1, first character of the edit control is always announced
  • with the try build, the charactor at the caret is announced as expected

I have tested with Microsoft Office 365 Business (Version 1901) with English experience / Windows 10 (64bit) Version 1809 with English experience.

Discussion in Japanese is as follows:
nvdajp/nvdajp#104

Copy link
Collaborator

@LeonarddeR LeonarddeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not yet been able to test this code though, but it looks good.

if e and e.cachedAutomationID=="CellEdit":
obj=UIA(UIAElement=e)
obj.parent=api.getFocusObject()
return obj
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be override the AutoProperty here, as I assume the lifetime of this focusRedirect will be as long as the Excel6 Window itself?
self.focusRedirect = obj

In that case,

e=UIAHandler.handler.lastFocusedUIAElement
if e and e.cachedAutomationID=="CellEdit":
obj=UIA(UIAElement=e)
obj.parent=api.getFocusObject()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this set to the focus object instead of self? What is the focus object supposed to be? What happens if the parent is'nt overridden at all?

…nt must be set. also increase search count, and only set parent if previous focus was an ExcelCell.
@lukaszgo1
Copy link
Contributor

I have tested in Excel 2010 and editing cells still works.

@zstanecic
Copy link
Contributor

zstanecic commented Feb 18, 2019 via email

@michaelDCurran
Copy link
Member Author

michaelDCurran commented Feb 18, 2019 via email

@zstanecic
Copy link
Contributor

zstanecic commented Feb 19, 2019 via email

@LeonarddeR
Copy link
Collaborator

LeonarddeR commented Feb 19, 2019

Here, it works with Excel 365 version 16.0.11231.20174. However, when I focus the edit cell edit box and than alt+tab out and back in, I get the following output:
Book1 - Excel
Book1 tab control
Sheet Sheet1 tab selected
Grid data grid
"B" 2 data item selected 2 row 3 B column 3
Edit Cell edit
blank

@michaelDCurran michaelDCurran merged commit 31692c6 into master Feb 19, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.1 milestone Feb 19, 2019
@LeonarddeR
Copy link
Collaborator

@michaelDCurran: It puzzles me a bit that this is merged while @zstanecic didn't report it was fixed for him. Or am I missing something? There is also the focus ancestry issue I was experiencing when alt+tabbing out and back in.

@michaelDCurran
Copy link
Member Author

@LeonarddeR The issue you reported with the strange focus ancestry is due to the fact that when alt+tabbing back in, you were not originally on a cell, and therefore you are seeing the parent ancestry of the UIA edit control. There is probably some fancy way we could try and detect the current cell from the UIA edit control, but I feel that this scenario is very rare. The common usage will be starting on a cell and typing or pressing f2.
@zstanecic reported that the UIA edit control can never be found. I think that there is an entirely different cause here. some users had reported that at some point in the middle of Excel 2016's history, the edit control just stopped working. and it possibly had to do with uninstalling Skype for business. I.e. something to do with proxies.
I did also ask @zstanecic to perform some further tests, but he did not provide full details of his findings.
I possibly did merge this a little too quick. I would be happy to back this out if you believe this is not complete enough. Though for the majority of Excel 2016 users, now they can edit cells.

@michaelDCurran
Copy link
Member Author

Actually, there is no way around the focus ancestry thing as it seems that all Excel's object model calls fail while a cell is being edited. So we would never be able to locate the cell.

@LeonarddeR
Copy link
Collaborator

I possibly did merge this a little too quick. I would be happy to back this out if you believe this is not complete enough. Though for the majority of Excel 2016 users, now they can edit cells.

Nope, it is ok and I'm happy with the change. I just wanted to make sure that you took the reported issues into account when merging this, and as you did, it is ok. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

after installing nvda next 14998 can not edit cells in excel
6 participants