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
Next Next commit
Use a helper to toggle screen layout so only BrowseModeDocumentTreeIn…
…terceptor needs to override script_toggleScreenLayout
  • Loading branch information
SaschaCowley committed Jan 22, 2026
commit a1bf01f2fa85bff2ed10b4be2a9d2eb9e35f5a18
16 changes: 14 additions & 2 deletions source/browseMode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,15 @@ def _iterTextStyle(
"kb:,": "movePastEndOfContainer",
}

def _toggleScreenLayout(self) -> None:
"""Toggles whether the document is presented as it appears visually, or with interactive controls on their own lines.

Subclasses that support toggling this option should implement this method.

:raises NotImplementedError: If toggling this option is not supported by this document.
"""
raise NotImplementedError

@script(
description=_(
# Translators: the description for the toggleScreenLayout script.
Expand All @@ -2641,8 +2650,11 @@ def _iterTextStyle(
gesture="kb:NVDA+v",
)
def script_toggleScreenLayout(self, gesture):
Comment thread
SaschaCowley marked this conversation as resolved.
Outdated
# Translators: The message reported for not supported toggling of screen layout
ui.message(_("Not supported in this document."))
try:
self._toggleScreenLayout()
except NotImplementedError:
# Translators: The message reported for not supported toggling of screen layout
ui.message(_("Not supported in this document."))

def updateAppSelection(self):
"""Update the native selection in the application to match the browse mode selection in NVDA."""
Expand Down
18 changes: 5 additions & 13 deletions source/virtualBuffers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import NVDAHelper
import XMLFormatting
import scriptHandler
from scriptHandler import script
import api
import controlTypes
import textInfos.offsets
Expand Down Expand Up @@ -688,18 +687,11 @@ def script_refreshBuffer(self, gesture):
# Translators: the description for the refreshBuffer script on virtualBuffers.
script_refreshBuffer.__doc__ = _("Refreshes the document content")

@script(
description=_(
# Translators: the description for the toggleScreenLayout script on virtualBuffers.
"Toggles on and off if the screen layout is preserved while rendering the document content",
),
gesture="kb:NVDA+v",
)
def script_toggleScreenLayout(self, gesture):
config.conf["virtualBuffers"]["useScreenLayout"] = not config.conf["virtualBuffers"][
"useScreenLayout"
]
if config.conf["virtualBuffers"]["useScreenLayout"]:
def _toggleScreenLayout(self):
Comment thread
seanbudd marked this conversation as resolved.
newUseScreenLayout = config.conf["virtualBuffers"]["useScreenLayout"] = not config.conf[
"virtualBuffers"
]["useScreenLayout"]
if newUseScreenLayout:
# Translators: Presented when use screen layout option is toggled.
ui.message(_("Use screen layout on"))
else:
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
### Bug Fixes

* In Firefox browse mode, the accessible name of form controls (such as checkboxes and radio buttons) is now correctly announced when the control has an `aria-label` and an associated `<label>` element that contains only `aria-hidden` content. (#19409, @bramd)
* The "Toggles on and off if the screen layout is preserved while rendering the document content" item in the "Browse mode" category of the Input Gestures dialog now behaves correctly. (#18378)
* In Microsoft Word with UIA enabled, page changes are now correctly announced when navigating table rows that span multiple pages. (#19386, @akj)
* Fixed excessive resource usage and highlight flickering when using Visual Highlight. (#17434, @hwf1324)

Expand All @@ -32,6 +33,8 @@

Please refer to [the developer guide](https://download.nvaccess.org/documentation/developerGuide.html#API) for information on NVDA's API deprecation and removal process.

* Subclasses of `browseMode.BrowseModeDocumentTreeInterceptor` that support screen layout being on and off should override the `_toggleScreenLayout` method, rather than implementing `script_toggleScreenLayout` directly. (#19487)

#### Deprecations

<!-- Beyond this point, Markdown should not be linted, as we don't modify old change log sections. -->
Expand Down
Loading