Skip to content

Commit

Permalink
Merge pull request #6479 from frenzibyte/disable-dropdown-search-bar-…
Browse files Browse the repository at this point in the history
…on-mobile

Disable dropdown searching on mobile when no hardware keyboard is attached
  • Loading branch information
smoogipoo authored Jan 2, 2025
2 parents f8f27dd + 925a834 commit b3dfdba
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public abstract partial class DropdownSearchBar : VisibilityContainer, IFocusMan
{
public Bindable<string> SearchTerm { get; } = new Bindable<string>();

[Resolved]
private GameHost host { get; set; } = null!;

[Resolved]
private IDropdown dropdown { get; set; } = null!;

Expand All @@ -30,9 +33,6 @@ public bool AlwaysDisplayOnFocus
{
alwaysDisplayOnFocus = value;

if (inputSource != null)
inputSource.AlwaysDisplayOnFocus = value;

if (IsLoaded)
updateTextBoxVisibility();
}
Expand Down Expand Up @@ -62,10 +62,7 @@ private void load()

protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
inputSource = new DropdownTextInputSource(parent.Get<TextInputSource>(), parent.Get<GameHost>())
{
AlwaysDisplayOnFocus = AlwaysDisplayOnFocus
};
inputSource = new DropdownTextInputSource(parent.Get<TextInputSource>(), parent.Get<GameHost>());

var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(typeof(TextInputSource), inputSource);
Expand Down Expand Up @@ -120,7 +117,7 @@ private void updateMenuState()
/// </summary>
private void updateTextBoxVisibility()
{
bool showTextBox = AlwaysDisplayOnFocus || !string.IsNullOrEmpty(SearchTerm.Value);
bool showTextBox = !host.OnScreenKeyboardOverlapsGameWindow && (AlwaysDisplayOnFocus || !string.IsNullOrEmpty(SearchTerm.Value));
State.Value = textBox.HasFocus && showTextBox ? Visibility.Visible : Visibility.Hidden;
}

Expand Down Expand Up @@ -179,9 +176,7 @@ bool IFocusManager.ChangeFocus(Drawable? potentialFocusTarget)

private class DropdownTextInputSource : TextInputSource
{
public bool AlwaysDisplayOnFocus { get; set; }

private bool allowTextInput => !host.OnScreenKeyboardOverlapsGameWindow || AlwaysDisplayOnFocus;
private bool allowTextInput => !host.OnScreenKeyboardOverlapsGameWindow;

private readonly TextInputSource platformSource;
private readonly GameHost host;
Expand Down

0 comments on commit b3dfdba

Please sign in to comment.