Focus stays on the window instead of a RichEdit control after Alt+Tab back to it
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- operating-systems
Research direction
The focus-event flow lives in the MSAA handling code, including processFocusWinEvent and OrderedWinEventLimiter.flushEvents in the IAccessibleHandler package, with _shouldGetEvents deferring foreground events. Start by reproducing the RichEdit focus loss with the limiter's maxFocusItems lowered, then check the log for the dropped OBJID_CLIENT focus event. Done means focus lands on the edit field after Alt+Tab, verified across repeated returns.
Written by the indexing model from the issue text.
Description
Steps to reproduce
- Restart NVDA with add-ons disabled.
- Open a window with a read-only rich edit control. It reproduces both in a separate wxPython process and inside NVDA's process. The quickest way is the Python console (NVDA+control+z):
import wx
f = wx.Frame(None, title="Focus repro")
t = wx.TextCtrl(f, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH)
t.SetValue("text")
f.Show(); f.Maximize(); t.SetFocus()
- Alt+Tab to another window, then Alt+Tab back.
- Press the arrow keys.
- Repeat steps 3 and 4 a few times.
To make it reproduce more often, lower the focus limit first:
import IAccessibleHandler.internalWinEventHandler as h; h.winEventLimiter.maxFocusItems = 2
Actual behavior
NVDA announces only the window title. NVDA+tab reports the window, not the edit field. The caret does move (Windows beeps at the first/last line), but NVDA doesn't read it.
Switching back with Windows+number doesn't reproduce it.
Expected behavior
NVDA reports the edit field and tracks the caret.
NVDA logs, crash dumps and other attachments
MSAA debug log, on return to the window:
- In one core cycle the limiter receives: foreground of the wx window, focus on
RICHEDIT50WOBJID_CLIENT, a stale foreground ofXamlExplorerHostIslandWindow(the task switcher), focus onRICHEDIT50Wwith a positive objectID (e.g. 6), and two focus events from the task switcher. - The stale foreground triggers
_shouldGetEventsforeground deferral for two cycles, so all of these end up in one flush. OrderedWinEventLimiter.flushEventskeeps only the lastmaxFocusItems(4) focus/foreground events, so theOBJID_CLIENTfocus event is dropped.- The remaining focus event with objectID 6 can't be resolved:
AccessibleObjectFromEvent failed ... Could not instantiate an NVDAObject. It looks like a UIA event proxied to a winEvent, while NVDA handles this window via MSAA.[^1] - Only the foreground event is processed, so focus lands on the window.
Hook received winEvent: EVENT_OBJECT_FOCUS, window 1248016 (RICHEDIT50W), objectID OBJID_CLIENT, childID 0, process 15320 (nvda)
Hook received winEvent: EVENT_SYSTEM_FOREGROUND, window 196674 (XamlExplorerHostIslandWindow), objectID OBJID_WINDOW, childID 0, process 7348 (explorer)
Hook received winEvent: EVENT_OBJECT_FOCUS, window 1248016 (RICHEDIT50W), objectID 6, childID 0, process 15320 (nvda)
Foreground still 1051574 (wxWindowNR). Deferring until foreground is 196674 (XamlExplorerHostIslandWindow), defer count 1
Foreground still 1051574 (wxWindowNR). Deferring until foreground is 196674 (XamlExplorerHostIslandWindow), defer count 2
Emitting winEvent EVENT_SYSTEM_FOREGROUND, window 1051574 (wxWindowNR), ...
Emitting winEvent EVENT_OBJECT_FOCUS, window 1248016 (RICHEDIT50W), objectID 6, ...
oleacc.AccessibleObjectFromEvent failed with [WinError -2147467259]. WinEvent: window 1248016 (RICHEDIT50W), objectID 6, childID 0, process 15320 (nvda)
Could not instantiate an NVDAObject for winEvent: EVENT_OBJECT_FOCUS, window 1248016 (RICHEDIT50W), objectID 6, childID 0, process 15320 (nvda)
The NVDA log viewer doesn't show the issue: its onActivate refresh delays the focus change, so the OBJID_CLIENT focus event survives the limiter.[^1]
Possible fix: in processFocusWinEvent, when a focus event with a positive objectID can't be resolved for a non-UIA window that has the focus in its thread, fall back to its OBJID_CLIENT. Tested locally with the window in a separate process: without the fix NVDA landed on the field in 2 of 17 returns, with the fix in 14 of 14. It fixes every return where any focus event of the field survives the limiter. It doesn't help when the limiter drops both focus events of the field.
[^1]: The analysis was done with the help of an AI assistant. The steps above follow from the log, but the statements marked with this footnote are interpretations and may be inaccurate.
System configuration
NVDA installed/portable/running from source
Installed and running from source.
NVDA version
Installed: alpha-58000,a4a89720 (2027.1.0.58000)
Source: source-master-732d1ce (2027.1.0.0)
Windows version
Windows 11 25H2 (AMD64) build 26200.9550
Name and version of other software in use when reproducing the issue
None.
Other information about your system
Other questions
Does the issue still occur after restarting your computer?
Yes
Have you tried any other versions of NVDA? If so, please report their behaviors
Installed and from source, hashes provided above.
If NVDA add-ons are disabled, is your problem still occurring?
Yes.
Does the issue still occur after you run the System Accessibility Repair Tool in NVDA's tools menu?
Yes
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 842
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 56
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nvaccess/nvda
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
needs-technical-investigation p5 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
nvaccess/nvda#21085 · 7 comments ·
Maintainers usually reply within 1 day
-
Braille Viewer draws two braille patterns wrongly (U+28CC, U+2873) because of glyph errors in FreeMono-FixedBraille.ttfMay be free again A pull request for this issue was closed without being merged. Openaudience/a11y-tester good first issue p4 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nvaccess/nvda#21022 · 3 comments ·
Maintainers usually reply within 1 day
-
api-breaking-change audience/nvda-dev p5 release/blocking release/blocking-beta triaged
Difficulty 2/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
p5 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100