This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
gwen-dotnet/Gwen/Control/Property/Text.cs

60 lines
1.7 KiB
C#
Raw Normal View History

using System;
namespace Gwen.Control.Property
{
/// <summary>
/// Text property.
/// </summary>
public class Text : Base
{
protected readonly TextBox m_TextBox;
/// <summary>
/// Initializes a new instance of the <see cref="Text"/> class.
/// </summary>
/// <param name="parent">Parent control.</param>
public Text(Control.Base parent) : base(parent)
{
m_TextBox = new TextBox(this);
m_TextBox.Dock = Pos.Fill;
m_TextBox.ShouldDrawBackground = false;
m_TextBox.TextChanged += OnValueChanged;
}
/// <summary>
/// Property value.
/// </summary>
public override string Value
{
get { return m_TextBox.Text; }
set { base.Value = value; }
}
/// <summary>
/// Sets the property value.
/// </summary>
/// <param name="value">Value to set.</param>
/// <param name="fireEvents">Determines whether to fire "value changed" event.</param>
public override void SetValue(string value, bool fireEvents = false)
{
m_TextBox.SetText(value, fireEvents);
}
/// <summary>
/// Indicates whether the property value is being edited.
/// </summary>
public override bool IsEditing
{
get { return m_TextBox.HasFocus; }
}
/// <summary>
/// Indicates whether the control is hovered by mouse pointer.
/// </summary>
public override bool IsHovered
{
get { return base.IsHovered | m_TextBox.IsHovered; }
}
}
}