From 9f1e0eadd003c49b8dc569169a5f1f0042ddc710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 16 Apr 2026 13:27:37 -0600 Subject: [PATCH] Support Ctrl+Tab / Ctrl+Shift+Tab to switch tabs in the UI --- Common/Input/InputState.h | 4 ++++ Common/UI/TabHolder.cpp | 18 ++++++++++++++++++ Common/UI/TabHolder.h | 1 + 3 files changed, 23 insertions(+) diff --git a/Common/Input/InputState.h b/Common/Input/InputState.h index c48737cb84..bf7da2dd37 100644 --- a/Common/Input/InputState.h +++ b/Common/Input/InputState.h @@ -165,6 +165,10 @@ struct TouchInput { double timestamp; }; +#undef MOD_CTRL +#undef MOD_ALT +#undef MOD_SHIFT + enum class KeyInputFlags { DOWN = 1 << 0, UP = 1 << 1, diff --git a/Common/UI/TabHolder.cpp b/Common/UI/TabHolder.cpp index 2a29c11267..6d94bb4004 100644 --- a/Common/UI/TabHolder.cpp +++ b/Common/UI/TabHolder.cpp @@ -333,6 +333,24 @@ bool ChoiceStrip::Key(const KeyInput &input) { } return true; } + + // Support Ctrl+Tab / Ctrl+Shift+Tab as well, as these are common shortcuts for tab switching even outside of browsers. + if (input.keyCode == NKCODE_TAB && (input.flags & KeyInputFlags::MOD_CTRL)) { + if (input.flags & KeyInputFlags::MOD_SHIFT) { + if (selected_ > 0) { + SetSelection(selected_ - 1, true); + } else if (!choices_.empty()) { + SetSelection(choices_.size() - 1, true); + } + } else { + if (selected_ < (int)choices_.size() - 1) { + SetSelection(selected_ + 1, true); + } else { + SetSelection(0, true); + } + } + return true; + } } return ViewGroup::Key(input); } diff --git a/Common/UI/TabHolder.h b/Common/UI/TabHolder.h index 2ce46a5b20..096efbb061 100644 --- a/Common/UI/TabHolder.h +++ b/Common/UI/TabHolder.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h"