-
-
Notifications
You must be signed in to change notification settings - Fork 716
Update braille when control+v, control+x, control+y, control+z, backspace or control+backspace is pressed and UIA not used in ms word #15491
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
Conversation
cc: @LeonarddeR |
@@ -47,12 +47,6 @@ def _get_ignoreEditorRevisions(self): | |||
ignoreFormatting=False | |||
|
|||
def event_caret(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to research why this code was ever added. It should be possible to do this with a git blame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelDCurran if super(WordDocument,self).event_caret() is not executed there seems to be problem that braille is not always updated when backspace is pressed (problem should occur at least if backspace is pressed and hold down).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tent to agree with @LeonarddeR that checking with git blame in which commit this was introduced is safer. Would you be able to do this?
|
||
def event_UIA_notification(self, activityId=None, **kwargs): | ||
# #10851: in recent Word 365 releases, UIA notification will cause NVDA to announce edit functions | ||
# such as "delete back word" when Control+Backspace is pressed. | ||
if activityId == "AccSN2": # Delete activity ID | ||
return | ||
super(WordDocument, self).event_UIA_notification(**kwargs) | ||
# Try to ensure that braille is updated when UIA is not used and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is a good idea to do this here. There must be another event we're missing, and if not, it's simply a bug in Word that needs to be reported and fixed on their end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that sometimes event_caret (IAccessible\winword.py) is fired when control+z is pressed and sometimes not. UIA_notification event seems to be fired always.
I think I have tried to add textChange (and textInsert/textRemove) events to IAccessible\winword.py but I suppose they are not fired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you intend this to work for Non UIA cases with this code? If so I think it's a false positive, because this code is not active when UIA is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When "Use UI Automation to access Microsoft Word document controls Only when necessary" event_UIA_notification is fired when pressing control+x and control+z.
Can reason be that object model is not available for some reason and thus UIA is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a notification event is fired for undo but neither a caret nor a text change event is fired, this is something Microsoft needs to fix.
Have you double checked other editing commands: del, shift+del, shift+backspace, redo (control+Y), etc.? |
@burmancomp, keep in mind that "Use UI Automation to access Microsoft Word document controls" only applies to situations when NVDA queries informations such as curent line, table, current text formatting, etc. I does not apply to event triggered by an action and thus to UIA notifications. So does not apply to notifications received when performing control+Z or control+U. Also to check if you are using UIA or object model to access Word document, you can press NVDA+F1 and look at dev info at the end of the log. If the dev info ends with UIA peroperties, you are accessing the document via UIA; else, if it ends with IAccessible properties, you are accessing it through object model. At last, beware to #13704 when testing with Word: be sure to change the focus at least once before doing tests. |
I don't think that's true. Word sends UIA notifications to its UIA control, so when that control is used, NVDA will receive those. If the object model is active and uIA is disabled for Word, the notifications will still be send but NVDA silently ignores them anyway. |
@LeonarddeR, I have just tested with Word 2016, version '16.0.16731.20234', with "Use UIA" option to "Only when necessary", and I have double checked that UIA is actually not used with looking at dev info in the log viewer. I can confirm that even if NVDA uses object model to access Word document, the following actions trigger UIA notifications:
|
Wow, that's pretty spooky. In any case, that means we should not touch the notification code for now. |
If event_UIA_notification code is not touched how braille is updated? I am suspicious that Microsoft would fix this. It is issue of older object model. |
Please update the PR title to be more descriptive |
@LeonarddeR what do you think about code now? |
This is not going to work for older version of Word that don't provide UIA notifications. |
How old office versions NVDA should support (is there official policy)? Support of office 2010 ended on october 2020, and support of office 2013 ended in april 2023. @CyrilleB79 told in his comment about UIA notifications. This pull request could be limited to try to solve issue from 2016. |
See test results for failed build of commit cc1375fb40 |
See test results for failed build of commit 51a93734a0 |
See test results for failed build of commit c9815650e8 |
As to letters y or z sometimes typed when control+y or control+z is pressed and held down, I suppose it is not issue of this pull request. I have noticed that when backspace or control+backspace are pressed, held down and then released speech may be inaccurate (not reporting most recent deletion). This may happen also when using current main branch so I suppose this behavior is not merely issue of this pull request. |
Please put the word "fixes" or "closes" before the issue number in the PR description so GitHub automatically links the issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @burmancomp
Link to issue number:
fixes #3276
Summary of the issue:
After paste, cut, redo, undo, backspace or control+backspace braille line was not necessarily updated when using object model.
Description of user facing changes
Braille line and review position should always be updated when using object model ("Use UI Automation to access Microsoft Word document controls" is not set to always in NVDA's advanced settings category), and paste (control+v), cut (control+x), redo (control+y) or undo (control+z / alt+backspace) is pressed. Braille should be also updated when using object model and backspace or control+backspace is pressed and held down.
Braille and review position are also updated when using UIA, and braille is tethered to review and review follows caret.
Description of development approach
To get control+v, control+x, control+y, control+z and alt+backspace to work, added helper script
script_updateBrailleAndReviewPosition
to NVDAObjects.IAccessible\winword.WordDocument, and assigned corresponding keyboard shortcuts to it. Minor modification ofevent_caret
so that braille is always updated when caret event is executed fromscript_updateBrailleAndReviewPosition
. To update braille always when backspace or control+backspace are pressed and held down, overridden_backspaceScriptHelper
function.In addition, to get braille updated when tethered to review and when review follows caret, modified event_textChange in UIA\wordDocument.py.
Testing strategy:
Tested with word 2019 (version 2308 Build 16.0.16731.20182) 32-bit using Albatross 80. More testing with various configurations would be needed.
Known issues with pull request:
none at this moment
Code Review Checklist: