osu/osu.Game/Overlays/Options/OptionTextBox.cs

53 lines
1.5 KiB
C#
Raw Normal View History

2017-02-07 04:52:19 +00: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;
using osu.Framework.Configuration;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
{
public class OptionTextBox : OsuTextBox
{
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-10 23:25:20 +00:00
protected override string InternalText
2016-11-10 23:15:30 +00:00
{
2016-11-10 23:25:20 +00:00
get { return base.InternalText; }
2016-11-10 23:15:30 +00:00
set
{
2017-02-07 04:52:19 +00:00
base.InternalText = value;
if (bindable != null)
2016-11-10 23:15:30 +00:00
bindable.Value = value;
}
2017-02-07 04:52:19 +00:00
}
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);
}
}
2016-11-10 23:15:30 +00:00
}