Skip to content

Commit

Permalink
better spoken forms for dynamic access
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Feb 23, 2024
1 parent 8ef818f commit f00accb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions core/overrides.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

from talon import actions, Context, settings, Module, app

ctx = Context()
Expand Down
2 changes: 1 addition & 1 deletion nvda/.addOn/sight-free-talon-server/buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _(arg):
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional)
"addon_minimumNVDAVersion" : "2019.3",
# Last NVDA version supported/tested
"addon_lastTestedNVDAVersion" : "2023.3.3",
"addon_lastTestedNVDAVersion" : "2023.3.",
# Add-on update channel (default is None, denoting stable releases,
# and for development releases, use "dev".)
# Do not change unless you know what you are doing!
Expand Down
28 changes: 20 additions & 8 deletions utils/access-focus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from talon import Module, ui, Context
from talon import Module, ui, Context, actions
from talon.windows import ax as ax

mod = Module()
Expand All @@ -12,25 +12,37 @@ def get_every_child(element: ax.Element):

ctx = Context()

mod.list("dynamic_children", desc="List of children of the active window")
mod.list("dynamic_children", desc="List of children accessibility elements of the active window")

@ctx.dynamic_list("user.dynamic_children")
def dynamic_children(_) -> dict[str,str]:
def dynamic_children(phrase) -> dict[str,str]:

root = ui.active_window().element
elements = list(get_every_child(root))

return {str(i.name): str(i.name) for i in elements}
spoken_forms = {}
for e in elements:
spoken_form = actions.user.create_spoken_forms(e.name, generate_subsequences=False)
if CAN_BE_SPOKEN := (len(spoken_form) > 0):
for form in spoken_form:
spoken_forms[form] = e.name

return spoken_forms

@mod.action_class
class Actions:

def focus_element_by_name(name: str):
"""Focuses on an element by name"""
root = ui.active_window().element
elements = list(get_every_child(root))
for element in elements:
if element.name == name or \
str(element.name).lower() == name:
element.invoke_pattern.invoke()
if str(element.name).lower() == str(name).lower():
try:
element.invoke_pattern.invoke()
except Exception as e:
actions.user.tts(f"Failed to focus {name}")
print(e)
break
else:
print("Element not found")
print("Element not found")
2 changes: 0 additions & 2 deletions utils/access-focus.talon
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
^access {user.dynamic_children}$:
user.focus_element_by_name(dynamic_children)


2 changes: 1 addition & 1 deletion utils/windows-utils.talon
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ extract text:

reader running:
res = user.is_nvda_running()
user.tts("{res}")
user.tts("{res}")

0 comments on commit f00accb

Please sign in to comment.