Skip to content

Conversation

@siliconsniffer
Copy link
Contributor

@siliconsniffer siliconsniffer commented Jan 2, 2026

Add compact, short information about your PR for easier understanding:

Note

I used an LLM Chatbot/Assistant during development, but I take full responsibility for the submitted changes.

  • Goal of the PR
    Improve keyboard-only navigation by outlining the currently focused element.
    Future gamepad support would also benefit from this.
  • How does the PR work?
    This PR adds a hard-coded white rectangle, which appears around the next focused element when tab is pressed.
  • Does it resolve any reported issue?
    Addresses Show GUI element focus #16137
    Closes Allow keyboard only use of formspecs #11392
    Related Formspec buttons mega-issue #14425
  • Does this relate to a goal in the roadmap?
    Not directly, maybe 2.3.
  • If not a bug fix, why is this PR needed? What usecases does it solve?
    This is an industry standard: OSes like Android or Windows and many applications, e.g., Firefox, have very similar functionality. It makes it easier to figure out which element is focused.
  • If you have used an LLM/AI to help with code or assets, you must disclose this.
    Disclosed.

To do

This PR is ready for review.

How to test

open luanti → press tab/shift+tab → observe that the focused element is outlined in white

Preview

2026-01-02.13-43-35.mp4

@sfan5 sfan5 added Feature ✨ PRs that add or enhance a feature Formspec labels Jan 2, 2026
@rubenwardy
Copy link
Contributor

I haven't tried this out yet. But I'd make sure the outline only appears when the keyboard or gamepad is used to focus, and not when clicking or otherwise focusing

@siliconsniffer
Copy link
Contributor Author

That's exactly what it does: the outline appears when pressing tab with or without shift and disappears when clicking somewhere with the mouse. It does not appear when pressing ctrl and tab.

@siliconsniffer
Copy link
Contributor Author

In my opinion #14531 can be addressed in a follow-up PR.

@siliconsniffer

This comment was marked as outdated.

@appgurueu
Copy link
Contributor

Currently, tables can be focused and can shift focus to the previous element but not the next. Is this behavior intended and expected by the user?

I would say no, "previous" and "next" should be symmetric.

@siliconsniffer
Copy link
Contributor Author

I agree and fixed this in dff25c2. This should be ready for a second round of reviews then.
What about the style? I sometimes find the outline hard to spot.

@siliconsniffer
Copy link
Contributor Author

This is how it looks with doubled thickness.
screenshot_20260103_132437

@appgurueu
Copy link
Contributor

What about the style? I sometimes find the outline hard to spot.

I think ideally there should be a formspec way of styling the color and maybe the thickness, for two reasons: In a light (white) style, the outline might be barely noticeable; game developers might want the outline to fit in with the color scheme of their menus. But it's probably fine to add such an option later?

2px thickness seems ok to me, though of course it depends a bit on screen resolution.

@siliconsniffer

This comment was marked as outdated.

@rubenwardy
Copy link
Contributor

If we allow styling, it should still be possible for users to override to make it very obvious for accessibility reasons

Also we have a focus selector for buttons already, but no focus-visible selector or an outline style property

@SmallJoker
Copy link
Member

The feature works as described - but unlike in other apps (e.g. webbrowser), the focussed element is not actively brought into the visible part of the frame.
Example: hold Tab in the Settings menu. I would expect it to automatically scroll down such that the focussed element can be seen.

@sfan5 sfan5 added this to the 5.15.0 milestone Jan 4, 2026
@siliconsniffer
Copy link
Contributor Author

autoscroll.mp4

@siliconsniffer
Copy link
Contributor Author

autoscroll_vert.mp4

@siliconsniffer

This comment was marked as outdated.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature ✨ PRs that add or enhance a feature Formspec One approval ✅ ◻️

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow keyboard only use of formspecs

5 participants