Skip to content

Commit f8ea8da

Browse files
authored
Merge pull request #196 from lippdev/fix/picker-keeps-focus
fix: give the focus back to the row that opened a picker
2 parents a448c1a + 96d4670 commit f8ea8da

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎CHANGELOG.en-US.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ English (US) release notes, mirroring CHANGELOG.md (Brazilian Portuguese). Befor
55
## [Unreleased]
66
### Changes
77
- Home: clicking a launcher (or pressing A on it) only picks what will open; **Play now** is what starts. Before, the click went straight into console mode, so picking looked like opening. With a controller or the keyboard, the focus moves down to **Play now** after the pick, so a second A plays. (#193)
8+
### Fixes
9+
- System and Session: picking an option from a list (resolution, audio output, how to turn the other screens off...) or closing it with B leaves the focus on the same row. Before, it went back to the category or the first screen, and you had to scroll down all over again. (#196)
810

911
## [1.7.0-beta.2]
1012
### Fixes

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Notas em português do Brasil; a versão em inglês (Estados Unidos) fica em `CH
55
## [Unreleased]
66
### Mudanças
77
- Início: clicar num iniciador (ou apertar A nele) só escolhe o que vai abrir; quem começa é **Jogar agora**. Antes o clique já entrava no modo console, e escolher parecia abrir sozinho. No controle e no teclado, o foco desce para **Jogar agora** depois da escolha, então um segundo A joga. (#193)
8+
### Correções
9+
- Sistema e Sessão: escolher uma opção numa lista (resolução, saída de áudio, como desligar as outras telas...) ou fechá-la com B deixa o foco na mesma linha. Antes ele voltava para a categoria ou para a primeira tela, e era preciso descer tudo de novo. (#196)
810

911
## [1.7.0-beta.2]
1012
### Correções

‎docs/TESTING.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,12 @@ Pré-condições: a opção **Tirar o ponteiro do mouse do caminho** ligada (é
636636
- [ ] Fechar o Playnite depois disso encerra a sessão e a mesa volta como estava ("Restore: concluído com sucesso", sem "Não foi possível desconectar"). Resultado: ______
637637
- [ ] Com a TV como tela de jogo e os dois monitores da mesa desligados pela sessão, abrir e encerrar várias sessões seguidas. Se o log mostrar "Telas: a tela de jogo passou de … para …", a resolução da TV é aplicada, o jogo abre na TV e a volta religa os monitores da mesa nas posições certas (o log da volta mostra "telas com outro nome desde o backup"). Resultado: ______
638638

639+
## Foco volta para a linha depois de uma lista (#196)
640+
641+
- [ ] Sistema, com o controle: descer até uma opção que não seja a primeira (ex.: Como desligar as outras telas), abrir com A, escolher outro valor com A. O foco fica nessa mesma opção. Fechar outra lista com B também volta para a linha dela. Resultado: ______
642+
- [ ] Sessão: Saída de áudio e Resolução, escolhendo um valor ou fechando com B: o foco volta para o ajuste, não para a primeira tela. Resultado: ______
643+
- [ ] Com o mouse: clicar numa opção, escolher um valor; a lista fecha e a página não pula. Resultado: ______
644+
639645
## Interface única e tour guiado (1.7.0)
640646

641647
Pré-condições: um `config.json` sem `consoleTourDone` (vale para quem atualiza de uma versão anterior, mesmo tendo visto o tutorial antigo). Teste com controle, só com mouse e só com teclado.

‎src/ConsoleMode/Views/ConsoleHomeView.xaml.cs‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public sealed partial class ConsoleHomeView : UserControl
2323
private static Style? _cardStyle;
2424
private static Style? _launchTileStyle;
2525
private Control? _lastSettingsRow;
26+
/// <summary>The row whose picker is open (or was, until the focus goes back to it).</summary>
27+
private Control? _pickerOpener;
2628
private readonly ScrollEdges _rowsEdges;
2729
/// <summary>When a category was last pressed with the mouse / touch: that click picks it, A goes into its options.</summary>
2830
private long _railPointerPressedAt = long.MinValue / 2;
@@ -166,10 +168,15 @@ private void OnViewModelChanged(object? sender, PropertyChangedEventArgs e)
166168
});
167169
break;
168170
case nameof(MainViewModel.IsPickerOpen):
171+
// The row that opened it still has the focus here: closing the picker lands back on that row (the
172+
// resolution, an audio output...), not on the first one of the page.
173+
if (ViewModel.IsPickerOpen && !IsFocusInside(PickerPanel))
174+
_pickerOpener = Root.XamlRoot is { } root ? FocusManager.GetFocusedElement(root) as Control : null;
169175
DispatcherQueue.TryEnqueue(() =>
170176
{
171177
if (ViewModel.IsPickerOpen) FocusPickerSelection();
172-
else if (ViewModel.IsConsoleSettingsOpen) FocusSystemRow();
178+
else if (BackToPickerOpener()) { }
179+
else if (ViewModel.IsConsoleSettingsOpen || ViewModel.IsSystemTab && _lastSettingsRow is not null) FocusSystemRow();
173180
else FocusDefault();
174181
});
175182
break;
@@ -256,6 +263,19 @@ private void FocusDefault()
256263
(FocusManager.FindFirstFocusableElement(ScreenCards) as Control)?.Focus(FocusState.Keyboard);
257264
}
258265

266+
/// <summary>
267+
/// The picker closed (a value picked or B): back to the row that opened it, if it is still on screen. A choice can
268+
/// rebuild the page under it (another resolution list, say); then the caller falls back to the usual spot.
269+
/// </summary>
270+
private bool BackToPickerOpener()
271+
{
272+
var opener = _pickerOpener;
273+
_pickerOpener = null;
274+
if (opener is null || opener.XamlRoot is null || opener.Visibility != Visibility.Visible || !opener.IsEnabled) return false;
275+
if (!IsInside(opener, Root) || IsInside(opener, PickerPanel)) return false;
276+
return opener.Focus(FocusState.Keyboard);
277+
}
278+
259279
/// <summary>Land on the current value so A confirms it and the stick moves from there.</summary>
260280
private void FocusPickerSelection()
261281
{

0 commit comments

Comments
 (0)