Sodium Reloaded (Unofficial)

Sodium Reloaded (Unofficial)

0 Downloads

Space cannot be used to activate UI elements on Sodium screens

haykam821 opened this issue ยท 5 comments

commented

In a recent Minecraft version, the user interface was updated to allow for space to be pressed to activate elements in addition to the previously-working enter key. However, Sodium doesn't appear to respond to space for keyboard navigation, only enter.

The root cause seems to be various checks for the enter key specifically:

https://github.com/CaffeineMC/sodium-fabric/blob/c937156e37d221216f284639fc8c51b30facf91e/src/main/java/me/jellysquid/mods/sodium/client/gui/options/control/TickBoxControl.java#L83 https://github.com/CaffeineMC/sodium-fabric/blob/c937156e37d221216f284639fc8c51b30facf91e/src/main/java/me/jellysquid/mods/sodium/client/gui/widgets/FlatButtonWidget.java#L88 https://github.com/CaffeineMC/sodium-fabric/blob/c937156e37d221216f284639fc8c51b30facf91e/src/main/java/me/jellysquid/mods/sodium/client/gui/options/control/CyclingControl.java#L115

Vanilla uses the KeyCodes.isToggle method to check whether a key is space, enter, or keypad enter within widgets; the method should be a direct replacement for the above checks. I am willing to open a pull request to fix this issue.

This issue can be reproduced with Minecraft 1.20.4 and the build of the latest commit as of this issue: 0.5.6+git.c937156 from c937156.

commented

Ah, seems like an oversight during porting. I think we might have also had some issue where using SPACE caused other interaction issues. Needs to be investigated again.

commented

From what I can tell, keyboard navigation and particularly the space key works fine, though there are some slight oddities compared to vanilla I've noticed otherwise that could also be improved:

  • Cycling options do not make a clicking noise when activated with the keyboard
  • Sliders do not need to be activated to be adjusted
  • Tabs act more like the statistics screen in having discrete buttons rather than the create world screen in having a single focus and using the arrows keys to change navigation
  • Tabs cannot be selected globally using Cmd+1
  • Selecting a tab blurs even if the focused element is kept on the new tab or the tab is the same
  • The donation prompt is not keyboard accessible at all
  • The high contrast resource pack gives a black background but no contrast between elements (already has a pull request: #1904)

Those issues don't seem to affect the space key specifically, so they can be fixed independently, and I am also willing to open pull requests for those issues. I can also open groups of issues so that these issues can be better tracked (tabs could be solved in one go, for example). The high contrast issue in particular would seem to need extra care since the UI elements are manually drawn rather than from a texture.

commented

This issue was incorrectly closed by GitHub on merge because it was linked to the pull request.

commented

From above, I can group the tab issues into a larger pull request since the tab issues are somewhat intertwined. For example, the focus blurring is likely related to tab not working the first time after changing a tab, and both of those issues are likely caused by the screen's children being cleared when changing tabs.

High contrast being unsupported is now covered by #2306.

That leaves the following issues from the above list which are minor and don't impede any keyboard navigation but are still worth fixing:

  • Cycling options do not make a clicking noise when activated with the keyboard (the option still has visual feedback)
  • Sliders do not need to be activated to be adjusted (this behavior in vanilla is meant to allow navigating to a left or right element on the screen, which isn't applicable here)
commented

Thanks for looking into it. If you want to contribute to fix the issues with keyboard navigation, feel free to. Larger pull requests are not an issue per-say but we generally prefer to have individual commits in the tree for each problem fixed.

Unfortunately, the GUI code is a bit of a mess and I'm not sure how difficult it will be. But if you do open pull requests, we'll try to merge into the Sodium 0.5.x branches rather than defer to Sodium 0.6.

I've been trying to open additional issues from this one (since having evergreen issues is generally not good) and have created the A-accessibility label to cover them. When everything else has been opened, we'll close this one.