Skip to content

First control does not receive focus automatically when window is shown #312

@PatrykMis

Description

@PatrykMis

Description

In classic WinAPI applications, the first control capable of receiving focus (i.e., with WS_TABSTOP) automatically gets focus when the window is shown. This behavior ensures immediate keyboard accessibility and is crucial for screen reader compatibility (e.g., JAWS, NVDA).

In native-windows-gui, no control receives focus by default after window.set_visible(true), unless it is explicitly set using control.set_focus(). This has been observed with TextBox, but may apply to other controls like Button, ListBox, etc.

As a result:

  • The application starts with no active control
  • The user must press Tab before any control is interactable
  • Screen readers may not detect a valid focus target on startup
  • Text cursors do not appear automatically in editable controls

Expected behavior

The first focusable control (i.e., one with WS_TABSTOP) should automatically receive focus when the window becomes visible - consistent with WinAPI behavior.

Suggestions

  • Ensure focus is assigned to the first focusable control after set_visible(true) if no other control has it.
  • Alternatively, include WS_TABSTOP in default flag sets for focusable controls, and consider adding a focus manager behavior in NWG core.

Environment

  • native-windows-gui version: latest (1.0.13)
  • Windows version: 10
  • Rust version: 1.88.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions