mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Don't auto-focus textboxes when on screen keyboard would cause inconvenience
This commit is contained in:
@ -3,7 +3,9 @@
|
||||
|
||||
using osuTK.Graphics;
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -21,9 +23,16 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private bool focus;
|
||||
|
||||
private bool allowImmediateFocus => host?.OnScreenKeyboardOverlapsGameWindow != true;
|
||||
|
||||
public void TakeFocus()
|
||||
{
|
||||
if (allowImmediateFocus) GetContainingInputManager().ChangeFocus(this);
|
||||
}
|
||||
|
||||
public bool HoldFocus
|
||||
{
|
||||
get { return focus; }
|
||||
get { return allowImmediateFocus && focus; }
|
||||
set
|
||||
{
|
||||
focus = value;
|
||||
@ -32,6 +41,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private GameHost host;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host)
|
||||
{
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
// We may not be focused yet, but we need to handle keyboard input to be able to request focus
|
||||
public override bool HandleNonPositionalInput => HoldFocus || base.HandleNonPositionalInput;
|
||||
|
||||
|
Reference in New Issue
Block a user