Ctrl+1..9 to jump to a tab by its current position (main window + Preferences)

Ctrl and a number selects the Nth tab as it currently appears — positions are live, so they follow
the user's tab reordering and the pan/EQ tab's show/hide. Handled in ProcessCmdKey on both the main
window and the Preferences dialog; focuses the tab strip afterwards so NVDA reads the new tab (like
Ctrl+Tab). Matches Andre's readout app. Manual updated.

Build clean; --selftest passes; deployed to both test folders. Held for next release.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ednunp
2026-07-08 14:31:22 +01:00
co-authored by Claude Opus 4.8
parent 597b002f01
commit fcc3cdc793
4 changed files with 46 additions and 4 deletions
+19
View File
@@ -7221,6 +7221,25 @@ public sealed class MainForm : Form
/// </summary>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Ctrl+1..9 — switch to the main tab at that position. Positions are LIVE: they shift as the
// user reorders tabs (Preferences → Appearance) and the pan/EQ tab may be hidden, so the number
// always means "the Nth tab as it currently appears". Same idea as Andre's readout app.
if ((keyData & Keys.Modifiers) == Keys.Control)
{
int tabNum = (keyData & Keys.KeyCode) switch
{
>= Keys.D1 and <= Keys.D9 => (keyData & Keys.KeyCode) - Keys.D1 + 1,
>= Keys.NumPad1 and <= Keys.NumPad9 => (keyData & Keys.KeyCode) - Keys.NumPad1 + 1,
_ => 0,
};
if (tabNum >= 1 && tabNum <= mainTabControl.TabPages.Count)
{
mainTabControl.SelectedIndex = tabNum - 1;
mainTabControl.Focus(); // focus the tab strip so NVDA reads the new tab, like Ctrl+Tab
return true;
}
}
// Defensive gate for the global menu shortcuts that change state (Ctrl+R = toggle
// recording, Ctrl+S = save profile). The default WinForms behaviour fires these
// shortcuts any time the form has keyboard focus — which technically includes the
+21
View File
@@ -1013,6 +1013,27 @@ internal sealed class PreferencesDialog : Form
/// focus event (without the transition WinForms can treat focus as unchanged and stay silent).
/// * NotifyFocus re-fires the MSAA focus event as belt-and-braces.
/// Ctrl+Tab still switches tabs from inside the page.</summary>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Ctrl+1..N switch to that tab by its current position — matches the main window.
if ((keyData & Keys.Modifiers) == Keys.Control)
{
int n = (keyData & Keys.KeyCode) switch
{
>= Keys.D1 and <= Keys.D9 => (keyData & Keys.KeyCode) - Keys.D1 + 1,
>= Keys.NumPad1 and <= Keys.NumPad9 => (keyData & Keys.KeyCode) - Keys.NumPad1 + 1,
_ => 0,
};
if (n >= 1 && n <= tabs.TabPages.Count)
{
tabs.SelectedIndex = n - 1;
tabs.Focus();
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);