Table of Contents

Class GuiElementSwitch

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll
public class GuiElementSwitch : GuiElementControl, IDisposable
Inheritance
GuiElementSwitch
Implements
Inherited Members
Extension Methods

Constructors

GuiElementSwitch(ICoreClientAPI, Action<bool>, ElementBounds, double, double)

Creates a switch which can be toggled.

public GuiElementSwitch(ICoreClientAPI capi, Action<bool> OnToggled, ElementBounds bounds, double size = 30, double padding = 4)

Parameters

capi ICoreClientAPI

The Client API

OnToggled Action<bool>

The event that happens when the switch is flipped.

bounds ElementBounds

The bounds of the element.

size double

The size of the switch. (Default: 30)

padding double

The padding on the outside of the switch (Default: 5)

Fields

On

Wether the switch has been toggled to On

public bool On

Field Value

bool

Properties

Focusable

Whether or not the element can be focused.

public override bool Focusable { get; }

Property Value

bool

Methods

ComposeElements(Context, ImageSurface)

Composes the elements.

public override void ComposeElements(Context ctxStatic, ImageSurface surface)

Parameters

ctxStatic Context

The context of the components.

surface ImageSurface

The surface of the GUI.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public override void Dispose()

OnKeyDown(ICoreClientAPI, KeyEvent)

The event fired when a key is held down.

public override void OnKeyDown(ICoreClientAPI api, KeyEvent args)

Parameters

api ICoreClientAPI

The client API

args KeyEvent

The key event arguments.

OnMouseDownOnElement(ICoreClientAPI, MouseEvent)

The event fired when the mouse is pressed while on the element. Called after OnMouseDown and tells the engine that the event is handled.

public override void OnMouseDownOnElement(ICoreClientAPI api, MouseEvent args)

Parameters

api ICoreClientAPI

The Client API

args MouseEvent

The mouse event args.

RenderInteractiveElements(float)

Renders the element as an interactive element.

public override void RenderInteractiveElements(float deltaTime)

Parameters

deltaTime float

The change in time.

SetValue(bool)

Sets the value of the switch on or off.

public void SetValue(bool on)

Parameters

on bool

on == true.