1
0
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:
Dean Herbert 2017-03-28 00:05:11 +09:00
parent 13272e6995
commit 768b3c4b4b
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 28 additions and 1 deletions

View File

@ -67,6 +67,8 @@ namespace osu.Game.Overlays
optionsSection.Bounding = true;
FadeIn(transition_time, EasingTypes.OutQuint);
optionsSection.TriggerFocus();
}
protected override void PopOut()

View File

@ -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);
}
}
}
}