Merge pull request #25286 from frenzibyte/search-text-box-select-all

Automatically select existing search text when opening settings
This commit is contained in:
Dean Herbert 2023-10-31 12:14:00 +09:00 committed by GitHub
commit 3060cf1438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 4 deletions

View File

@ -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.

View File

@ -140,6 +140,17 @@ public void TestTextboxFocusAfterNestedPanelEscape()
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()
{

View File

@ -135,7 +135,7 @@ private void load()
},
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Child = searchTextBox = new SeekLimitedSearchTextBox
Child = searchTextBox = new SettingsSearchTextBox
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,

View 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();
}
}
}

View File

@ -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. -->

View File

@ -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>