mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:45:09 +08:00
Merge pull request #25286 from frenzibyte/search-text-box-select-all
Automatically select existing search text when opening settings
This commit is contained in:
commit
3060cf1438
@ -10,7 +10,7 @@
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.1012.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.1030.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Fody does not handle Android build well, and warns when unchanged.
|
||||
|
@ -140,6 +140,17 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSearchTextBoxSelectedOnShow()
|
||||
{
|
||||
SearchTextBox searchTextBox = null!;
|
||||
|
||||
AddStep("set text", () => (searchTextBox = settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First()).Current.Value = "some text");
|
||||
AddAssert("no text selected", () => searchTextBox.SelectedText == string.Empty);
|
||||
AddRepeatStep("toggle visibility", () => settings.ToggleVisibility(), 2);
|
||||
AddAssert("search text selected", () => searchTextBox.SelectedText == searchTextBox.Current.Value);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Child = searchTextBox = new SeekLimitedSearchTextBox
|
||||
Child = searchTextBox = new SettingsSearchTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.TopCentre,
|
||||
|
22
osu.Game/Overlays/SettingsSearchTextBox.cs
Normal file
22
osu.Game/Overlays/SettingsSearchTextBox.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public partial class SettingsSearchTextBox : SeekLimitedSearchTextBox
|
||||
{
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
base.OnFocus(e);
|
||||
|
||||
// on mobile platforms, focus is not held by the search text box, and the select all feature
|
||||
// will not make sense on it, and might annoy the user when they try to focus manually.
|
||||
if (HoldFocus)
|
||||
SelectAll();
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2023.1012.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2023.1030.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1023.0" />
|
||||
<PackageReference Include="Sentry" Version="3.40.0" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
|
@ -23,6 +23,6 @@
|
||||
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.1012.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.1030.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user