Control IsEnabled 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 virtual bool IsEnabled { get; set; }

Property Value

Type: Boolean
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.ScrollbarTests
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.ButtonTests
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.InteractiveButtonTests
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.RadioButtonTests
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.RadioDialogTests
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.SliderTests
Remarks

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

3 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test, CloseAfterFirstFrame]
public void DefaultsToEnabled()
{
    Assert.IsTrue(scrollbar.IsEnabled);
    Assert.AreEqual(Color.Gray, scrollbar.Color);
    Assert.AreEqual(Color.LightGray, scrollbar.Pointer.Color);
}
[Test, CloseAfterFirstFrame]
public void DisablingScrollbarDisablesPointer()
{
    scrollbar.IsEnabled = false;
    Assert.IsFalse(scrollbar.IsEnabled);
    Assert.IsFalse(scrollbar.Pointer.IsEnabled);
}
[Test]
public void RenderDisabledScrollbar()
{
    scrollbar.IsEnabled = false;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(Color.DarkGray, scrollbar.Color);
    Assert.AreEqual(Color.Gray, scrollbar.Pointer.Color);
}
Examples

3 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test]
public void RenderOneButtonEnablingAndDisablingAnother()
{
    var button2 = new Button(Rectangle.FromCenter(0.5f, 0.3f, 0.2f, 0.1f));
    button2.Clicked += () => button.IsEnabled = !button.IsEnabled;
}
[Test, CloseAfterFirstFrame]
public void DefaultsToEnabled()
{
    Assert.IsTrue(button.IsEnabled);
}
[Test, CloseAfterFirstFrame]
public void DisabledControlDoesNotRespondToClick()
{
    if (!IsMockResolver)
        return; //ncrunch: no coverage
    button.IsEnabled = false;
    bool clicked = false;
    button.Clicked += () => clicked = true;
    PressAndReleaseMouse(new Vector2D(0.53f, 0.52f), new Vector2D(0.53f, 0.52f));
    Assert.IsFalse(clicked);
    Assert.IsFalse(button.State.IsInside);
    Assert.AreEqual(Vector2D.Zero, button.State.RelativePointerPosition);
}
Examples

3 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test, ApproveFirstFrameScreenshot]
public void RenderDisabledInteractiveButton()
{
    button.IsEnabled = false;
}
[Test, CloseAfterFirstFrame]
public void DefaultsToEnabled()
{
    Assert.IsTrue(button.IsEnabled);
}
[Test, CloseAfterFirstFrame]
public void BeginningClickDoesNothingIfDisabled()
{
    button.IsEnabled = false;
    SetMouseState(State.Pressing, Vector2D.Half);
    Assert.AreEqual(BaseSize.Width, button.Size.Width, 0.05f);
}
Examples

2 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test, ApproveFirstFrameScreenshot]
public void RenderThreeRadioButtonsWithTheMiddleDisabled()
{
    new RadioButton(Top, "Hello");
    new RadioButton(Bottom, "Hey");
    centerButton.IsEnabled = false;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(Color.DarkGray, centerButton.Color);
}
[Test, CloseAfterFirstFrame]
public void DefaultsToEnabled()
{
    Assert.IsTrue(centerButton.IsEnabled);
    Assert.AreEqual(Color.Gray, centerButton.Color);
}
Examples

5 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test]
public void RenderRadioDialogWithThreeButtonsWithTheMiddleDisabled()
{
    var buttons = dialog.Get<List<RadioButton>>();
    buttons[1].IsEnabled = false;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(Color.Gray, buttons[0].Color);
    Assert.AreEqual(Color.DarkGray, buttons[1].Color);
}
[Test, CloseAfterFirstFrame]
public void ClickingRadioButtonDoesNotSelectItIfDisabled()
{
    var buttons = dialog.Get<List<RadioButton>>();
    buttons[1].IsEnabled = false;
    PressAndReleaseMouse(new Vector2D(0.35f, 0.5f));
    Assert.IsFalse(buttons[1].State.IsSelected);
}
[Test, CloseAfterFirstFrame]
public void ClickingDisabledRadioButtonDoesNotCauseTheOthersToUnselect()
{
    if (mouse == null)
        return; //ncrunch: no coverage 
    var buttons = dialog.Get<List<RadioButton>>();
    buttons[2].IsEnabled = false;
    PressAndReleaseMouse(new Vector2D(0.35f, 0.5f));
    PressAndReleaseMouse(new Vector2D(0.35f, 0.6f));
    Assert.IsTrue(buttons[1].State.IsSelected);
    Assert.IsFalse(buttons[2].State.IsSelected);
}
Examples

3 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test, CloseAfterFirstFrame]
public void DefaultProperties()
{
    Assert.IsTrue(slider.IsEnabled);
    Assert.AreEqual(Color.Gray, slider.Color);
    Assert.AreEqual(Color.LightGray, slider.Pointer.Color);
    Assert.AreEqual(0, slider.MinValue);
    Assert.AreEqual(100, slider.Value);
    Assert.AreEqual(100, slider.MaxValue);
}
[Test, CloseAfterFirstFrame]
public void DisablingSliderDisablesPointer()
{
    slider.IsEnabled = false;
    Assert.IsFalse(slider.IsEnabled);
    Assert.IsFalse(slider.Pointer.IsEnabled);
}
[Test]
public void RenderDisabledSlider()
{
    slider.IsEnabled = false;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(Color.DarkGray, slider.Color);
    Assert.AreEqual(Color.Gray, slider.Pointer.Color);
}
Examples

5 unit tests call DeltaEngine.Scenes.Controls.Control.IsEnabled
[Test, CloseAfterFirstFrame]
public void DefaultsToEnabled()
{
    Assert.IsTrue(topTextBox.IsEnabled);
}
[Test, ApproveFirstFrameScreenshot]
public void RenderOneEnabledAndOneDisabledTextBox()
{
    bottomTextBox.IsEnabled = false;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(Color.Gray, topTextBox.Color);
    Assert.AreEqual(Color.DarkGray, bottomTextBox.Color);
}
[Test, CloseAfterFirstFrame]
public void ClickingTextBoxDoesNotGivesItFocusIfItIsDisabled()
{
    topTextBox.IsEnabled = false;
    PressAndReleaseMouse(Top.Center);
    Assert.IsFalse(topTextBox.State.HasFocus);
}
See Also