Class Checkbox
A checkbox element to use inside of a UiSystem. A checkbox can be checked by pressing it and will stay checked until it is pressed again. For a checkbox that causes neighboring checkboxes to be deselected automatically, use RadioButton.
public class Checkbox : Element, IGenericDataHolder
- Inheritance
-
Checkbox
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
Checkbox(Anchor, Vector2, string, bool)
Creates a new checkbox with the given settings
public Checkbox(Anchor anchor, Vector2 size, string label, bool defaultChecked = false)
Parameters
anchor
AnchorThe checkbox's anchor
size
Vector2The checkbox's size
label
stringThe checkbox's label text
defaultChecked
boolThe default value of Checked
Fields
CanSelectDisabled
Whether this checkbox should be able to be selected even if it IsDisabled. If this is true, CanBeSelected will be able to return true even if IsDisabled is true.
public bool CanSelectDisabled
Field Value
Checkmark
The texture that is rendered on top of this checkbox when it is Checked.
public StyleProp<TextureRegion> Checkmark
Field Value
DisabledColor
The color that the checkbox uses for drawing when it IsDisabled.
public StyleProp<Color> DisabledColor
Field Value
- StyleProp<Color>
DisabledTexture
The texture that the checkbox uses when it IsDisabled. If this is null, it uses its default Texture.
public StyleProp<NinePatch> DisabledTexture
Field Value
HoveredColor
The color that this checkbox uses for drawing when it is hovered.
public StyleProp<Color> HoveredColor
Field Value
- StyleProp<Color>
HoveredTexture
The texture that this checkbox uses when it is hovered. If this is null, the default Texture is used.
public StyleProp<NinePatch> HoveredTexture
Field Value
Label
The label Paragraph that displays next to this checkbox
public Paragraph Label
Field Value
OnCheckStateChange
An event that is invoked when this checkbox's Checked property changes
public Checkbox.CheckStateChange OnCheckStateChange
Field Value
Texture
The texture that this checkbox uses for drawing.
public StyleProp<NinePatch> Texture
Field Value
Properties
CanBePressed
Set this field to false to disallow this element's OnPressed and OnSecondaryPressed events to be called.
public override bool CanBePressed { get; }
Property Value
CanBeSelected
Set this field to false to disallow the element from being selected. An unselectable element is skipped by automatic navigation and its OnSelected callback will never be called.
public override bool CanBeSelected { get; }
Property Value
Checked
Whether or not this checkbox is currently checked.
public bool Checked { get; set; }
Property Value
IsDisabled
Set this property to true to mark the checkbox as disabled. A disabled checkbox cannot be moused over, selected or toggled.
public virtual bool IsDisabled { get; set; }
Property Value
TextOffsetX
The width of the space between this checkbox and its Label
public StyleProp<float> TextOffsetX { get; set; }
Property Value
Methods
Draw(GameTime, SpriteBatch, float, SpriteBatchContext)
Draws this element and all of its children. Override this method to draw the content of custom elements.
Note that, when this is called, SpriteBatch.Begin
has already been called with custom Transform etc. applied.
public override void Draw(GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context)
Parameters
time
GameTimeThe game's time
batch
SpriteBatchThe sprite batch to use for drawing
alpha
floatThe alpha to draw this element and its children with
context
SpriteBatchContextThe sprite batch context to use for drawing
InitStyle(UiStyle)
Initializes this element's StyleProp<T> instances using the ui system's UiStyle.
protected override void InitStyle(UiStyle style)
Parameters
style
UiStyleThe new style
SetAreaAndUpdateChildren(RectangleF)
Sets this element's Area to the given RectangleF and invokes the OnElementAreaUpdated event. This method also updates all of this element's Children's areas. Note that this method does not take into account any auto-sizing, anchoring or positioning, and so it should be used sparingly, if at all.
public override void SetAreaAndUpdateChildren(RectangleF area)
Parameters
area
RectangleF
- See Also