Skip to content

Commit

Permalink
Report link destination & character formatting browseableMessages giv…
Browse files Browse the repository at this point in the history
…en close and copy buttons.
  • Loading branch information
Luke Davis authored and Luke Davis committed Apr 11, 2024
1 parent 6355374 commit 9dfb23d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,10 @@ def _reportFormattingHelper(self, info, browseable=False):
ui.browseableMessage(
message,
# Translators: title for formatting information dialog.
_("Formatting")
_("Formatting"),
copyButton=True,
# Translators: Close button label
closeButtonText=_("Close")
)

@staticmethod
Expand Down Expand Up @@ -3950,7 +3953,7 @@ def script_reportLinkDestination(
) -> None:
"""Generates a ui.message or ui.browseableMessage of a link's destination, if focus or caret is
positioned on a link, or an element with an included link such as a graphic.
@param forceBrowseable: skips the press once check, and displays the browseableMessage version.
:param forceBrowseable: skips the press once check, and displays the browseableMessage version.
"""
try:
ti: textInfos.TextInfo = api.getCaretPosition()
Expand Down Expand Up @@ -3987,7 +3990,10 @@ def script_reportLinkDestination(
linkDestination,
# Translators: Informs the user that the window contains the destination of the
# link with given title
title=_("Destination of: {name}").format(name=obj.name)
title=_("Destination of: {name}").format(name=obj.name),
# Translators: Close button label, recommending to press escape to close the message.
closeButtonText=_("Press escape to close"),
copyButton=True
)
elif presses == 0: # One press
ui.message(linkDestination) # Speak the link
Expand Down
10 changes: 5 additions & 5 deletions source/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ def browseableMessage(
title: Optional[str] = None,
isHtml: bool = False,
closeButtonText: Optional[str] = None,
copyButtonText: Optional[str] = None
copyButton: bool = False
) -> None:
"""Present a message to the user that can be read in browse mode.
The message will be presented in an HTML document.
:param message: The message in either html or text.
:param title: The title for the message, defaults to "NVDA Message".
:param isHtml: Whether the message is html, defaults to False.
:param closeButtonText: Text to use as label for a "close" button, defaults to None, meaning no close button.
:param copyButtonText: Text to use as label for a "copy" (to clipboard) button, defaults to None,
meaning no copy button.
:param copyButton: Whether to include a "copy" (to clipboard) button, defaults to False.
"""
if isRunningOnSecureDesktop():
import wx # Late import to prevent circular dependency.
Expand Down Expand Up @@ -134,8 +133,9 @@ def browseableMessage(
d.add("message", message)
if closeButtonText is not None:
d.add("closeButtonText", closeButtonText)
if copyButtonText is not None:
d.add("copyButtonText", copyButtonText)
if copyButton:
# Translators: The text of a button to copy the text of the window to the clipboard.
d.add("copyButtonText", _("Copy"))
dialogArgsVar = automation.VARIANT(d)
gui.mainFrame.prePopup()
windll.mshtml.ShowHTMLDialogEx(
Expand Down

0 comments on commit 9dfb23d

Please sign in to comment.