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
ICoreClientAPIThe Client API
OnToggled
Action<bool>The event that happens when the switch is flipped.
bounds
ElementBoundsThe bounds of the element.
size
doubleThe size of the switch. (Default: 30)
padding
doubleThe padding on the outside of the switch (Default: 5)
Fields
On
Wether the switch has been toggled to On
public bool On
Field Value
Properties
Focusable
Whether or not the element can be focused.
public override bool Focusable { get; }
Property Value
Methods
ComposeElements(Context, ImageSurface)
Composes the elements.
public override void ComposeElements(Context ctxStatic, ImageSurface surface)
Parameters
ctxStatic
ContextThe context of the components.
surface
ImageSurfaceThe 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
ICoreClientAPIThe client API
args
KeyEventThe 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
ICoreClientAPIThe Client API
args
MouseEventThe mouse event args.
RenderInteractiveElements(float)
Renders the element as an interactive element.
public override void RenderInteractiveElements(float deltaTime)
Parameters
deltaTime
floatThe change in time.
SetValue(bool)
Sets the value of the switch on or off.
public void SetValue(bool on)
Parameters
on
boolon == true.