Force Tab focus to reach all controls on macOS

macOS defaults keyboard navigation to text fields and lists only, so Tab
(and the gamepad navigation that synthesizes it) can't move focus between
controls on the settings page. Other platforms already default to this.
This commit is contained in:
kynoptic
2026-06-03 20:58:00 -04:00
committed by Cameron Gutman
parent 534ce02756
commit 7c93aaf659
+11
View File
@@ -1,4 +1,5 @@
#include <QGuiApplication>
#include <QStyleHints>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QIcon>
@@ -753,6 +754,16 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
#ifdef Q_OS_DARWIN
// macOS defaults "Keyboard navigation" to text fields and lists only, which
// prevents Tab (and the gamepad navigation that synthesizes it) from moving
// focus between non-text controls on the settings page. Force Tab to reach
// all controls so keyboard and gamepad UI navigation work without requiring
// the user to enable a system accessibility setting. Other platforms already
// default to this behavior.
app.styleHints()->setTabFocusBehavior(Qt::TabFocusAllControls);
#endif
#ifdef Q_OS_UNIX
// Register signal handlers to arbitrate between SDL and Qt.
// NB: This has to be done after the QGuiApplication is constructed to