1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 00:33:21 +08:00
osu-lazer/osu.Game/Overlays/Options/OptionTextBox.cs

53 lines
1.5 KiB
C#
Raw Normal View History

2016-12-06 17:56:20 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
2017-01-30 19:29:04 +08:00
using osu.Framework.Configuration;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
2016-11-11 07:15:30 +08:00
namespace osu.Game.Overlays.Options
{
public class OptionTextBox : OsuTextBox
2016-11-11 07:15:30 +08:00
{
private Bindable<string> bindable;
public Bindable<string> Bindable
{
set
{
if (bindable != null)
bindable.ValueChanged -= bindableValueChanged;
bindable = value;
if (bindable != null)
{
base.Text = bindable.Value;
bindable.ValueChanged += bindableValueChanged;
}
}
}
2016-11-11 07:25:20 +08:00
protected override string InternalText
2016-11-11 07:15:30 +08:00
{
2016-11-11 07:25:20 +08:00
get { return base.InternalText; }
2016-11-11 07:15:30 +08:00
set
{
2016-11-11 07:25:20 +08:00
base.InternalText = value;
2016-11-11 07:15:30 +08:00
if (bindable != null)
bindable.Value = value;
}
}
private void bindableValueChanged(object sender, EventArgs e)
{
Text = bindable.Value;
}
protected override void Dispose(bool isDisposing)
{
if (bindable != null)
bindable.ValueChanged -= bindableValueChanged;
base.Dispose(isDisposing);
}
}
}