From f9493848a5874203fa09f7bf70cf037ea86db36d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 18 Dec 2023 16:57:07 +0900 Subject: [PATCH 1/2] Fix dropdowns showing popup keyboard on mobile even when search bar is initially hidden --- .../Graphics/UserInterface/DropdownSearchBar.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs b/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs index a95560da50..31fdf4bb19 100644 --- a/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs +++ b/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs @@ -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!; @@ -68,6 +72,11 @@ protected override void LoadComplete() public void ObtainFocus() { + // On mobile platforms, let's not make the keyboard popup unless the dropdown is intentionally searchable. + bool willShowOverlappingKeyboard = host?.OnScreenKeyboardOverlapsGameWindow == true; + if (willShowOverlappingKeyboard && !AlwaysDisplayOnFocus) + return; + textBoxInputManager.ChangeFocus(textBox); obtainedFocus = true; From 378784d1795769f82516d10db91465521c2b8b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 18 Dec 2023 18:28:39 +0100 Subject: [PATCH 2/2] Fix dropdowns showing keyboard on mobile even harder --- osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs b/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs index 31fdf4bb19..f42c0e286c 100644 --- a/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs +++ b/osu.Framework/Graphics/UserInterface/DropdownSearchBar.cs @@ -73,9 +73,17 @@ 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;