Let tab walk every box again

Tab was doing what space does, which is wrong. N1MM's EntryWindow does not
touch the tab key — ProcessCmdKey only remaps NumPad Enter — so tab there is
plain navigation through the boxes in the order they are laid out: the reports
at tab index 3 and 4, the name at 26, the section at 30, the zone at 32, the
comment at 40. Only space goes through NextTab, which is the walk that steps
over the reports.

So tab now walks every box, reports, name and comment included, and shift and
tab walk back. Space is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-28 10:32:38 +00:00
parent 8956c2fd22
commit 7e7ce41477
2 changed files with 43 additions and 13 deletions

View File

@@ -311,9 +311,9 @@ public sealed partial class EntryWindow : Window
e.Handled = true;
session.SwapRadio();
break;
case Key.Tab when FocusedIsEntryBox():
case Key.Tab when FocusedIsEntryBox() || FocusedIsNoteBox():
e.Handled = true;
MoveFocus(forward: !e.KeyModifiers.HasFlag(KeyModifiers.Shift));
MoveToNextBox(forward: !e.KeyModifiers.HasFlag(KeyModifiers.Shift));
break;
case Key.Z when e.KeyModifiers.HasFlag(KeyModifiers.Control):
e.Handled = true;
@@ -394,9 +394,9 @@ public sealed partial class EntryWindow : Window
boxes[0].Focus();
}
/// Tab and space walk the callsign box and the exchange boxes, and round
/// again, as N1MM's do. The name and comment boxes are not in the walk,
/// because they are not part of the exchange; they are there for the mouse.
/// What space does: the callsign box and the exchange boxes, stepping over
/// the reports and over a box this station is not asked for, and round to
/// the callsign again. This is N1MM's NextTab.
private void MoveFocus(bool forward)
{
if (Logging is null || boxes.Count == 0)
@@ -428,6 +428,28 @@ public sealed partial class EntryWindow : Window
FocusEntryBox();
}
/// What tab does: every box in turn, reports, name and comment included,
/// and round again. N1MM does not touch the tab key, so tab there walks
/// the boxes in the order they are laid out, and this walks the same ones.
private void MoveToNextBox(bool forward)
{
if (Logging is null)
{
return;
}
List<TextBox> all = [.. boxes, .. new[] { nameBox, commentBox }.OfType<TextBox>()];
int at = all.FindIndex(box => box.IsFocused);
int next = ((at < 0 ? 0 : at) + (forward ? 1 : -1) + all.Count) % all.Count;
if (next < boxes.Count)
{
Logging.Entry.FocusOn(next);
FocusEntryBox();
return;
}
all[next].Focus();
all[next].CaretIndex = all[next].Text?.Length ?? 0;
}
private void FocusEntryBox()
{
if (Logging is null)
@@ -457,6 +479,8 @@ public sealed partial class EntryWindow : Window
private bool FocusedIsEntryBox() => boxes.Any(b => b.IsFocused);
private bool FocusedIsNoteBox() => nameBox?.IsFocused == true || commentBox?.IsFocused == true;
/// The buttons N1MM puts under its function keys. Each one does what its
/// key does, so there is one place deciding what happens.
private void OnStopSending(object? sender, RoutedEventArgs e)