Fix #27105: Mod search box doesnt track external focus changes

In the Mod selection area, the search bar's focus could be changed by pressing TAB.
However, when clicking outside of the search bar, the focus would be killed but two TABs were required to get the focus back on the search bar.
This happened because the action of clicking in an empty area would trigger the search bar to change its appearence, but not its internal state.
In my solution, I made the OnClick function aware of the search bar's state, so it would not only change its appearance, but also its state.
Now, after clicking in an empty area, there is only needed one TAB to select the search box again, as expected.
This commit is contained in:
Mafalda Fernandes 2024-04-01 19:21:05 +01:00
parent ca525f6a91
commit 16276dfcd6
1 changed files with 8 additions and 4 deletions

View File

@ -420,7 +420,7 @@ private IEnumerable<ColumnDimContainer> createColumns()
yield return new ColumnDimContainer(new ModPresetColumn
{
Margin = new MarginPadding { Right = 10 }
});
}, this);
}
yield return createModColumnContent(ModType.DifficultyReduction);
@ -438,7 +438,7 @@ private ColumnDimContainer createModColumnContent(ModType modType)
column.Margin = new MarginPadding { Right = 10 };
});
return new ColumnDimContainer(column);
return new ColumnDimContainer(column, this);
}
private void createLocalMods()
@ -899,13 +899,17 @@ internal partial class ColumnDimContainer : Container
[Resolved]
private OsuColour colours { get; set; } = null!;
public ColumnDimContainer(ModSelectColumn column)
private ModSelectOverlay modSelectOverlayInstance;
public ColumnDimContainer(ModSelectColumn column, ModSelectOverlay modSelectOverlay)
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Child = Column = column;
column.Active.BindTo(Active);
this.modSelectOverlayInstance = modSelectOverlay;
}
[BackgroundDependencyLoader]
@ -953,7 +957,7 @@ protected override bool OnClick(ClickEvent e)
RequestScroll?.Invoke(this);
// Killing focus is done here because it's the only feasible place on ModSelectOverlay you can click on without triggering any action.
Scheduler.Add(() => GetContainingInputManager().ChangeFocus(null));
modSelectOverlayInstance.setTextBoxFocus(false);
return true;
}