Skip to content

Commit b34d14a

Browse files
authored
Merge 717c970 into 180c9f2
2 parents 180c9f2 + 717c970 commit b34d14a

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

source/globalCommands.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# A part of NonVisual Desktop Access (NVDA)
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
5-
# Copyright (C) 2006-2022 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
5+
# Copyright (C) 2006-2023 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
66
# Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka, Accessolutions,
7-
# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith
7+
# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith, Luke Davis
88

99
import itertools
1010
from typing import (
@@ -3628,6 +3628,54 @@ def script_reloadPlugins(self, gesture):
36283628
# Translators: Presented when plugins (app modules and global plugins) are reloaded.
36293629
ui.message(_("Plugins reloaded"))
36303630

3631+
@script(
3632+
description=_(
3633+
# Translators: input help mode message for Report destination URL of navigator link command
3634+
"Report the destination URL of the link in the navigator object. "
3635+
"If pressed twice, shows the URL in a window for easier review."
3636+
),
3637+
gesture="kb:NVDA+k",
3638+
category=SCRCAT_TOOLS
3639+
)
3640+
def script_reportLinkDestination(
3641+
self, gesture: inputCore.InputGesture, forceBrowseable: bool = False
3642+
) -> None:
3643+
"""Generates a ui.message or ui.browseableMessage of a link's destination, if the navigator
3644+
object is a link, or an element with an included link such as a graphic.
3645+
@param forceBrowseable: skips the press once check, and displays the browseableMessage version.
3646+
"""
3647+
obj = api.getNavigatorObject()
3648+
if (
3649+
obj.role == controlTypes.role.Role.LINK # If it's a link, or
3650+
or controlTypes.state.State.LINKED in obj.states # if it isn't a link but contains one
3651+
):
3652+
if (
3653+
forceBrowseable # If a browseable message is preferred unconditionally, or
3654+
or scriptHandler.getLastScriptRepeatCount() > 0 # if pressed more than once
3655+
):
3656+
# Translators: Informs the user that the window contains the destination of the
3657+
# link with given title
3658+
ui.browseableMessage(obj.value, title=_("Destination of: {name}").format(name=obj.name))
3659+
else:
3660+
ui.message(obj.value) # Speak the link
3661+
else:
3662+
# Translators: Tell user that the command has been run on something that is not a link
3663+
ui.message(_("Not a link."))
3664+
3665+
@script(
3666+
description=_(
3667+
# Translators: input help mode message for Report URL of navigator link in a window command
3668+
"Reports the destination URL of the link in the navigator object in a window, "
3669+
"instead of just speaking it. May be preferred by braille users."
3670+
),
3671+
category=SCRCAT_TOOLS
3672+
)
3673+
def script_reportLinkDestinationInWindow(self, gesture: inputCore.InputGesture) -> None:
3674+
"""Uses the forceBrowseable flag of script_reportLinkDestination, to generate a
3675+
ui.browseableMessage of a link's destination.
3676+
"""
3677+
self.script_reportLinkDestination(gesture, True)
3678+
36313679
@script(
36323680
# Translators: Input help mode message for a touchscreen gesture.
36333681
description=_("Moves to the next object in a flattened view of the object navigation hierarchy"),

user_docs/en/userGuide.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ The actual commands will not execute while in input help mode.
222222
| 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 |
223223
| Read time | ``NVDA+f12`` | ``NVDA+f12`` | Pressing once reports the current time, pressing twice reports the date |
224224
| Report text formatting | ``NVDA+f`` | ``NVDA+f`` | Reports text formatting. Pressing twice shows the information in a window |
225+
| 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 |
225226

226227
+++ Toggle which information NVDA reads +++[ToggleWhichInformationNVDAReads]
227228
|| Name | Desktop key | Laptop key | Description |

0 commit comments

Comments
 (0)