mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Simplify exit logic of screens with textboxes using back button receptor
This commit is contained in:
@ -2,22 +2,20 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
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;
|
||||
using osu.Framework.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// A textbox which holds focus eagerly.
|
||||
/// </summary>
|
||||
public class FocusedTextBox : OsuTextBox
|
||||
public class FocusedTextBox : OsuTextBox, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public Action Exit;
|
||||
|
||||
private bool focus;
|
||||
|
||||
private bool allowImmediateFocus => host?.OnScreenKeyboardOverlapsGameWindow != true;
|
||||
@ -68,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
public override bool OnPressed(GlobalAction action)
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (action == GlobalAction.Back)
|
||||
{
|
||||
@ -79,14 +77,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnPressed(action);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void KillFocus()
|
||||
{
|
||||
base.KillFocus();
|
||||
Exit?.Invoke();
|
||||
}
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
|
||||
public override bool RequestsFocus => HoldFocus;
|
||||
}
|
||||
|
Reference in New Issue
Block a user