Support Ctrl+Tab / Ctrl+Shift+Tab to switch tabs in the UI

This commit is contained in:
Henrik Rydgård
2026-04-16 13:27:37 -06:00
parent 7c4fb8b084
commit 9f1e0eadd0
3 changed files with 23 additions and 0 deletions
+4
View File
@@ -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,
+18
View File
@@ -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);
}
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <string_view>
#include <functional>
#include "Common/UI/View.h"
#include "Common/UI/ViewGroup.h"