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

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

Merged
merged 30 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c911ac
fix 3276
burmancomp Sep 21, 2023
3d08f47
Merge branch 'master' into fix_3276
burmancomp Sep 23, 2023
2dadf66
Merge branch 'master' into fix_3276
burmancomp Sep 26, 2023
823daf6
run added code when UIA should not be used, and minor modifications
burmancomp Sep 26, 2023
02f94ed
minor fix
burmancomp Sep 26, 2023
3a96c9d
using helper scripts for paste, cut and undo
burmancomp Sep 26, 2023
6aa015e
some modifications
burmancomp Sep 27, 2023
8bc8c01
revert using api.getFocusObject
burmancomp Sep 27, 2023
94be5c7
Merge branch 'master' into fix_3276
burmancomp Sep 27, 2023
2e4c574
suggested modifications
burmancomp Sep 27, 2023
847ed52
change log entry modification
burmancomp Sep 29, 2023
e79c17f
Merge branch 'master' into fix_3276
burmancomp Sep 29, 2023
89ab7d8
refactored code to fix braille problem caused by modification of even…
burmancomp Oct 3, 2023
db5b953
Merge branch 'master' into fix_3276
burmancomp Oct 3, 2023
63d476a
Merge branch 'master' into fix_3276
burmancomp Oct 4, 2023
3f24e56
control+y, control+backspace, alt+backspace and minor modifications
burmancomp Oct 5, 2023
96e814f
Merge branch 'master' into fix_3276
burmancomp Oct 5, 2023
542e1b1
Merge branch 'master' into fix_3276
burmancomp Oct 6, 2023
40b6e8a
minor modifications
burmancomp Oct 6, 2023
ca9c4dd
retry
burmancomp Oct 6, 2023
357e88d
updated changes entry
burmancomp Oct 7, 2023
1af7bfe
suggested change
burmancomp Oct 7, 2023
31afc49
minor modification of changes entry
burmancomp Oct 7, 2023
7cdefd1
code style/docstring/changes entry modifications
burmancomp Oct 8, 2023
31f2703
minor changes
burmancomp Oct 9, 2023
d3c7cf4
Merge branch 'master' into fix_3276
burmancomp Oct 9, 2023
c1ba916
Merge branch 'master' into fix_3276
burmancomp Oct 10, 2023
be7ca0f
Merge branch 'master' into fix_3276
burmancomp Oct 17, 2023
c56fed9
suggested code refactoring
burmancomp Oct 18, 2023
269120c
Merge branch 'master' into fix_3276
burmancomp Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions source/NVDAObjects/IAccessible/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ def _get_ignoreEditorRevisions(self):
ignoreFormatting=False

def event_caret(self):
Copy link
Collaborator

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.

Copy link
Contributor Author

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).

Copy link
Contributor

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?

curSelectionPos=self.makeTextInfo(textInfos.POSITION_SELECTION)
lastSelectionPos=getattr(self,'_lastSelectionPos',None)
self._lastSelectionPos=curSelectionPos
if lastSelectionPos:
if curSelectionPos._rangeObj.isEqual(lastSelectionPos._rangeObj):
return
self._lastSelectionPos = self.makeTextInfo(textInfos.POSITION_SELECTION)
super(WordDocument,self).event_caret()

def _get_role(self):
Expand Down
16 changes: 15 additions & 1 deletion source/NVDAObjects/UIA/wordDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
)
from NVDAObjects import NVDAObject
from scriptHandler import script
import api
import eventHandler


"""Support for Microsoft Word via UI Automation."""
Expand Down Expand Up @@ -544,14 +546,26 @@ class WordDocument(UIADocumentWithTableNavigation,WordDocumentNode,WordDocumentB
def event_textChange(self):
burmancomp marked this conversation as resolved.
Show resolved Hide resolved
# Ensure Braille is updated when text changes,
# As Microsoft Word does not fire caret events when typing text, even though the caret does move.
braille.handler.handleCaretMove(self)
# Update braille also when tethered to review, and review position
# if review follows caret.
if not eventHandler.isPendingEvents("caret, self"):
burmancomp marked this conversation as resolved.
Show resolved Hide resolved
eventHandler.queueEvent("caret", self)

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

# ctrl-v, ctrl-x or ctrl-z is pressed.
burmancomp marked this conversation as resolved.
Show resolved Hide resolved
# Using getFocusObject because self does not work always.
if (
not UIAHandler.shouldUseUIAInMSWord(self.appModule)
and not eventHandler.isPendingEvents("caret", api.getFocusObject())
):
eventHandler.queueEvent("caret", api.getFocusObject())
log.debug(f"{self.appModule.appName}: enqueued caret event")

# The following overide of the EditableText._caretMoveBySentenceHelper private method
# Falls back to the MS Word object model if available.
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ What's New in NVDA
== Bug Fixes ==
- Reporting of object shortcut keys has been improved. (#10807)
- The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271)
- Braille is updated when control+v, control+x, control+z or backspace is pressed.
burmancomp marked this conversation as resolved.
Show resolved Hide resolved
It is also updated when typing text, and braille is tethered to review and
review follows caret. (#3276)
-

== Changes for Developers ==
Expand Down