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 21 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
36 changes: 35 additions & 1 deletion source/NVDAObjects/IAccessible/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@
import textInfos
import eventHandler
import scriptHandler
from scriptHandler import script
import ui
from . import IAccessible
from displayModel import EditableTextDisplayModelTextInfo
from ..behaviors import EditableTextWithoutAutoSelectDetection
import NVDAObjects.window.winword as winWordWindowModule
from speech import sayAll
import inputCore


class WordDocument(IAccessible, EditableTextWithoutAutoSelectDetection, winWordWindowModule.WordDocument):

treeInterceptorClass = winWordWindowModule.WordDocumentTreeInterceptor
shouldCreateTreeInterceptor=False
TextInfo = winWordWindowModule.WordDocumentTextInfo
# Should braille and review position be updated, set to True in
# L{script_updateBrailleAndReviewPosition}.
_fromUpdateBrailleAndReviewPosition = False

def _get_ignoreEditorRevisions(self):
try:
Expand All @@ -46,12 +51,15 @@ def _get_ignoreEditorRevisions(self):
#: True if formatting should be ignored (text only) such as for spellCheck error field
ignoreFormatting=False

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

Expand Down Expand Up @@ -369,6 +377,32 @@ def script_previousParagraph(self,gesture):
self._caretScriptPostMovedHelper(textInfos.UNIT_PARAGRAPH,gesture,None)
script_previousParagraph.resumeSayAllMode = sayAll.CURSOR.CARET

@script(
gestures=(
"kb:control+v", "kb:control+x", "kb:control+y", "kb:control+z",
"kb:alt+backspace", "kb:backspace", "kb:control+backspace"
)
)
def script_updateBrailleAndReviewPosition(self, gesture: inputCore.InputGesture) -> None:
"""Helper script to update braille and review position.
Caret event is not always fired when control+v, control+x, control+y
or control+z (alt+backspace) is pressed so enqueuing caret event for that.
When backspace or control+backspace is pressed and hold down, braille
may not always be updated. Allowing braille and review position updates
in L{event_caret} seems to fix that problem.
"""
# Ensuring braille and review position updates are allowed in caret event.
self._fromUpdateBrailleAndReviewPosition = True
# Speech output when backspace or control+backspace is pressed.
if gesture._get_displayName() == "backspace":
self.script_caret_backspaceCharacter(gesture)
elif gesture._get_displayName() == "ctrl+backspace":
self.script_caret_backspaceWord(gesture)
burmancomp marked this conversation as resolved.
Show resolved Hide resolved
else:
gesture.send()
if not eventHandler.isPendingEvents("caret", self):
eventHandler.queueEvent("caret", self)
burmancomp marked this conversation as resolved.
Show resolved Hide resolved

def focusOnActiveDocument(self, officeChartObject):
rangeStart=officeChartObject.Parent.Range.Start
self.WinwordApplicationObject.ActiveDocument.Range(rangeStart, rangeStart).Select()
Expand Down
6 changes: 5 additions & 1 deletion source/NVDAObjects/UIA/wordDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
)
from NVDAObjects import NVDAObject
from scriptHandler import script
import eventHandler


"""Support for Microsoft Word via UI Automation."""
Expand Down Expand Up @@ -544,7 +545,10 @@ 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):
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
Expand Down
4 changes: 4 additions & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ This option now announces additional relevant information about an object when t
- The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271)
- Multi line state is now correctly reported in applications using Java Access Bridge. (#14609)
- In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436)
- Braille is updated when control+v, control+x, control+y, control+z,
backspace or control+backspace is pressed in MS Word when uia is not used.
It is also updated with UIA, when typing text and braille is tethered to
review and review follows caret. (#3276)
-

== Changes for Developers ==
Expand Down