Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
55 changes: 53 additions & 2 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# A part of NonVisual Desktop Access (NVDA)
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.
# Copyright (C) 2006-2022 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
# Copyright (C) 2006-2023 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
# Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka, Accessolutions,
# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith
# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith, Luke Davis

import itertools
from typing import (
Expand Down Expand Up @@ -3628,6 +3628,57 @@ def script_reloadPlugins(self, gesture):
# Translators: Presented when plugins (app modules and global plugins) are reloaded.
ui.message(_("Plugins reloaded"))

@script(
description=_(
# Translators: input help mode message for Report destination URL of navigator link command
"Report the destination URL of the link in the navigator object. "
"If pressed twice, shows the URL in a window for easier review."
),
gesture="kb:NVDA+k",
category=SCRCAT_TOOLS
)
def script_reportLinkDestination(
self, gesture: inputCore.InputGesture, forceBrowseable: bool = False
) -> None:
"""Generates a ui.message or ui.browseableMessage of a link's destination, if the navigator
object is 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.
"""
obj = api.getNavigatorObject()
presses = scriptHandler.getLastScriptRepeatCount()
if (
obj.role == controlTypes.role.Role.LINK # If it's a link, or
or controlTypes.state.State.LINKED in obj.states # if it isn't a link but contains one
):
if (
presses == 1 # If pressed twice, or
or forceBrowseable # if a browseable message is preferred unconditionally
):
# Translators: Informs the user that the window contains the destination of the
# link with given title
ui.browseableMessage(obj.value, title=_("Destination of: {name}").format(name=obj.name))
elif presses == 0: # One press
ui.message(obj.value) # Speak the link
else: # Some other number of presses
return # Do nothing
else:
# Translators: Tell user that the command has been run on something that is not a link
ui.message(_("Not a link."))

@script(
description=_(
# Translators: input help mode message for Report URL of navigator link in a window command
"Reports the destination URL of the link in the navigator object in a window, "
"instead of just speaking it. May be preferred by braille users."
),
category=SCRCAT_TOOLS
)
def script_reportLinkDestinationInWindow(self, gesture: inputCore.InputGesture) -> None:
"""Uses the forceBrowseable flag of script_reportLinkDestination, to generate a
ui.browseableMessage of a link's destination.
"""
self.script_reportLinkDestination(gesture, True)

@script(
# Translators: Input help mode message for a touchscreen gesture.
description=_("Moves to the next object in a flattened view of the object navigation hierarchy"),
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ The actual commands will not execute while in input help mode.
| Read status bar | ``NVDA+end`` | ``NVDA+shift+end`` | Reports the Status Bar if NVDA finds one. Pressing twice will spell the information. Pressing three times will copy it to the clipboard |
| Read time | ``NVDA+f12`` | ``NVDA+f12`` | Pressing once reports the current time, pressing twice reports the date |
| Report text formatting | ``NVDA+f`` | ``NVDA+f`` | Reports text formatting. Pressing twice shows the information in a window |
| Report link destination | ``NVDA+k`` | ``NVDA+k`` | Pressing once speaks the destination URL of the link in the [navigator object #ObjectNavigation]. Pressing twice shows it in a window for more careful review |

+++ Toggle which information NVDA reads +++[ToggleWhichInformationNVDAReads]
|| Name | Desktop key | Laptop key | Description |
Expand Down