From 50ff514be840fc7d27672d94ad386e4dba6aabbb Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Fri, 29 May 2026 05:03:10 +0200 Subject: [PATCH] feat(tv): wrap on-screen keyboard focus at edges --- lib/widgets/tv_virtual_keyboard.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/widgets/tv_virtual_keyboard.dart b/lib/widgets/tv_virtual_keyboard.dart index fe9a373e..aa013c8f 100644 --- a/lib/widgets/tv_virtual_keyboard.dart +++ b/lib/widgets/tv_virtual_keyboard.dart @@ -356,16 +356,21 @@ class _TvVirtualKeyboardDialogState extends State<_TvVirtualKeyboardDialog> with } void _moveHorizontal(int delta) { - final nextColumn = _nextFocusableColumn(_row, _column + delta, delta); + var nextColumn = _nextFocusableColumn(_row, _column + delta, delta); + if (nextColumn == null) { + final wrapStart = delta > 0 ? 0 : _rows[_row].length - 1; + nextColumn = _nextFocusableColumn(_row, wrapStart, delta); + } if (nextColumn == null) return; + final column = nextColumn; setState(() { - _column = nextColumn; + _column = column; }); } void _moveVertical(int delta) { final rows = _rows; - final nextRow = (_row + delta).clamp(0, rows.length - 1).toInt(); + final nextRow = (_row + delta) % rows.length; final nextColumn = _nearestFocusableColumn(nextRow, _column); setState(() { _row = nextRow;