osu/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledTextBox.cs

51 lines
1.4 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-07-20 10:05:19 +00:00
2018-07-25 09:38:50 +00:00
using osu.Framework.Allocation;
2018-07-20 10:05:19 +00:00
using osu.Framework.Graphics;
2018-07-25 09:34:47 +00:00
using osu.Framework.Graphics.UserInterface;
2018-07-20 10:05:19 +00:00
using osu.Game.Graphics;
2018-07-24 06:46:24 +00:00
using osu.Game.Graphics.UserInterface;
2018-07-20 10:05:19 +00:00
2018-11-06 09:28:22 +00:00
namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents
2018-07-20 10:05:19 +00:00
{
2019-09-24 09:25:17 +00:00
public class LabelledTextBox : LabelledComponent<OsuTextBox>
2018-07-20 10:05:19 +00:00
{
2018-07-25 09:34:47 +00:00
public event TextBox.OnCommitHandler OnCommit;
public LabelledTextBox()
: base(false)
2018-07-20 10:05:19 +00:00
{
}
public bool ReadOnly
2018-07-20 10:05:19 +00:00
{
set => Component.ReadOnly = value;
2018-07-20 10:05:19 +00:00
}
2018-07-23 12:44:10 +00:00
public string PlaceholderText
2018-07-20 10:05:19 +00:00
{
set => Component.PlaceholderText = value;
2018-07-20 10:05:19 +00:00
}
2018-07-23 12:44:10 +00:00
public string Text
2018-07-20 10:05:19 +00:00
{
set => Component.Text = value;
2018-07-20 10:05:19 +00:00
}
2018-07-25 09:38:50 +00:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Component.BorderColour = colours.Blue;
2018-07-25 09:38:50 +00:00
}
2019-09-24 09:25:17 +00:00
protected override OsuTextBox CreateComponent() => new OsuTextBox
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
CornerRadius = CORNER_RADIUS,
}.With(t => t.OnCommit += (sender, newText) => OnCommit?.Invoke(sender, newText));
2018-07-20 10:05:19 +00:00
}
}