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

Enhance Microsoft Word Comment Command: Press Twice to Present Comment Content in Browsable message. #16800

Merged
merged 12 commits into from
Jul 12, 2024
19 changes: 15 additions & 4 deletions source/NVDAObjects/IAccessible/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,16 @@ def script_caret_moveByCell(self, gesture: inputCore.InputGesture) -> None:
braille.handler.handleCaretMove(self)

@script(
# Translators: a description for a script
description=_("Reports the text of the comment where the system caret is located."),
description=_(
# Translators: a description for a script
"Reports the text of the comment where the system caret is located."
"If pressed twice, presents the information in browse mode."
),
gesture="kb:NVDA+alt+c",
category=SCRCAT_SYSTEMCARET,
speakOnDemand=True,
)
def script_reportCurrentComment(self, gesture):
def script_reportCurrentComment(self, gesture: "inputCore.InputGesture") -> None:
info = self.makeTextInfo(textInfos.POSITION_CARET)
info.expand(textInfos.UNIT_CHARACTER)
fields = info.getTextWithFields(formatConfig={"reportComments": True})
Expand All @@ -401,7 +404,15 @@ def script_reportCurrentComment(self, gesture):
except COMError:
break
if text:
ui.message(text)
repeats = scriptHandler.getLastScriptRepeatCount()
if repeats == 0:
ui.message(text)
elif repeats == 1:
ui.browseableMessage(
text,
# Translators: title for Word comment dialog.
_("Comment"),
)
return
# Translators: a message when there is no comment to report in Microsoft Word
ui.message(_("No comments"))
Expand Down
21 changes: 18 additions & 3 deletions source/NVDAObjects/UIA/wordDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

import enum
from comtypes import COMError
import inputCore
import mathPres
import scriptHandler
from scriptHandler import isScriptWaiting
import textInfos
import UIAHandler
Expand Down Expand Up @@ -643,15 +645,28 @@ def _caretMoveBySentenceHelper(self, gesture, direction):
@script(
gesture="kb:NVDA+alt+c",
# Translators: a description for a script that reports the comment at the caret.
description=_("Reports the text of the comment where the system caret is located."),
description=_(
# Translators: a description for a script that reports the comment at the caret.
"Reports the text of the comment where the system caret is located."
" If pressed twice, presents the information in a browsable message"
),
category=SCRCAT_SYSTEMCARET,
speakOnDemand=True,
)
def script_reportCurrentComment(self, gesture):
def script_reportCurrentComment(self, gesture: "inputCore.InputGesture") -> None:
caretInfo = self.makeTextInfo(textInfos.POSITION_CARET)
commentInfo = getCommentInfoFromPosition(caretInfo)
if commentInfo is not None:
ui.message(getPresentableCommentInfoFromPosition(commentInfo))
text = getPresentableCommentInfoFromPosition(commentInfo)
repeats = scriptHandler.getLastScriptRepeatCount()
if repeats == 0:
ui.message(text)
elif repeats == 1:
ui.browseableMessage(
text,
# Translators: title for Word comment dialog.
_("Comment"),
)
else:
# Translators: a message when there is no comment to report in Microsoft Word
ui.message(_("No comments"))
Expand Down
2 changes: 2 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

### New Features

* Enhanced Microsoft Word comment command: press twice to present comment content in browsable message. (#16800, @Cary-Rowen)
* NVDA can now be configured to report font attributes in speech and braille separately. (#16755)


### Bug Fixes

* NVDA once again relies on events for caret movement in several cases, rather than only on manual querying of the caret position.
Expand Down
3 changes: 2 additions & 1 deletion user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,8 @@ The Elements List can list headings, links, annotations (which includes comments
#### Reporting Comments {#WordReportingComments}

<!-- KC:beginInclude -->
To report any comments at the current caret position, press NVDA+alt+c.
To report any comments at the current caret position, press `NVDA+alt+c`.
Pressing twice shows the information in a browsable message.
<!-- KC:endInclude -->
All comments for the document, along with other tracked changes, can also be listed in the NVDA Elements List when selecting Annotations as the type.

Expand Down