Skip to content

Commit

Permalink
Merge pull request #6080 from peppy/dropdown-search-mobile-allowance
Browse files Browse the repository at this point in the history
Fix dropdowns showing popup keyboard on mobile even when search bar is initially hidden
  • Loading branch information
peppy committed Dec 18, 2023
2 parents ba569bf + 378784d commit d267e0f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs
Expand Up @@ -5,12 +5,16 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Platform;
using osuTK;

namespace osu.Framework.Graphics.UserInterface
{
public abstract partial class DropdownSearchBar : VisibilityContainer
{
[Resolved]
private GameHost? host { get; set; }

private TextBox textBox = null!;
private PassThroughInputManager textBoxInputManager = null!;

Expand Down Expand Up @@ -68,6 +72,19 @@ protected override void LoadComplete()

public void ObtainFocus()
{
// On mobile platforms, let's not make the keyboard popup unless the dropdown is intentionally searchable.
// Unfortunately it is not enough to just early-return here,
// as even despite that the text box will receive focus via the text box input manager;
// it is necessary to cut off the text box input manager from parent input entirely.
// TODO: preferably figure out a better way to do this.
bool willShowOverlappingKeyboard = host?.OnScreenKeyboardOverlapsGameWindow == true;

if (willShowOverlappingKeyboard && !AlwaysDisplayOnFocus)
{
textBoxInputManager.UseParentInput = false;
return;
}

textBoxInputManager.ChangeFocus(textBox);
obtainedFocus = true;

Expand Down

0 comments on commit d267e0f

Please sign in to comment.