TextBox HasFocus Property Delta Engine Documentation

Namespace: DeltaEngine.Scenes.Controls
Assembly: DeltaEngine.Scenes (in DeltaEngine.Scenes.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public bool HasFocus { get; }

Property Value

Type: Boolean
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.TextBoxTests
Examples

4 unit tests call DeltaEngine.Scenes.Controls.TextBox.HasFocus
[Test, CloseAfterFirstFrame]
public void ClickingTextBoxGivesItFocus()
{
    if (!IsMockResolver)
        return; //ncrunch: no coverage
    Assert.IsFalse(topTextBox.State.HasFocus);
    PressAndReleaseMouse(Vector2D.One);
    Assert.IsFalse(topTextBox.State.HasFocus);
    PressAndReleaseMouse(Top.Center);
    Assert.IsTrue(topTextBox.State.HasFocus);
}
[Test, CloseAfterFirstFrame]
public void ClickingOneTextBoxCausesOtherTextBoxToLoseFocus()
{
    if (!IsMockResolver)
        return; //ncrunch: no coverage
    PressAndReleaseMouse(Top.Center);
    Assert.IsTrue(topTextBox.State.HasFocus);
    Assert.IsFalse(bottomTextBox.State.HasFocus);
    PressAndReleaseMouse(Bottom.Center);
    Assert.IsFalse(topTextBox.State.HasFocus);
    Assert.IsTrue(bottomTextBox.State.HasFocus);
    Assert.AreEqual(Color.Gray, topTextBox.Color);
    Assert.AreEqual(Color.LightGray, bottomTextBox.Color);
}
[Test, CloseAfterFirstFrame]
public void ClickingTextBoxDoesNotGivesItFocusIfItIsDisabled()
{
    topTextBox.IsEnabled = false;
    PressAndReleaseMouse(Top.Center);
    Assert.IsFalse(topTextBox.State.HasFocus);
}
See Also