mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Add better focus handling in the login form.
This commit is contained in:
parent
13272e6995
commit
768b3c4b4b
@ -67,6 +67,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
optionsSection.Bounding = true;
|
||||
FadeIn(transition_time, EasingTypes.OutQuint);
|
||||
|
||||
optionsSection.TriggerFocus();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
|
@ -11,12 +11,14 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using OpenTK;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Options.Sections.General
|
||||
{
|
||||
public class LoginOptions : OptionsSubsection, IOnlineComponent
|
||||
{
|
||||
private bool bounding = true;
|
||||
private LoginForm form;
|
||||
|
||||
protected override string Header => "Account";
|
||||
|
||||
@ -40,12 +42,14 @@ namespace osu.Game.Overlays.Options.Sections.General
|
||||
|
||||
public void APIStateChanged(APIAccess api, APIState state)
|
||||
{
|
||||
form = null;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case APIState.Offline:
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new LoginForm()
|
||||
form = new LoginForm()
|
||||
};
|
||||
break;
|
||||
case APIState.Failing:
|
||||
@ -82,6 +86,14 @@ namespace osu.Game.Overlays.Options.Sections.General
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
form?.TriggerFocus();
|
||||
}
|
||||
|
||||
protected override bool OnFocus(InputState state)
|
||||
{
|
||||
form?.TriggerFocus();
|
||||
return base.OnFocus(state);
|
||||
}
|
||||
|
||||
private class LoginForm : FillFlowContainer
|
||||
@ -144,6 +156,19 @@ namespace osu.Game.Overlays.Options.Sections.General
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnFocus(InputState state)
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(username.Text))
|
||||
username.TriggerFocus();
|
||||
else
|
||||
password.TriggerFocus();
|
||||
});
|
||||
|
||||
return base.OnFocus(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user