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
capiICoreClientAPIThe Client API
OnToggledAction<bool>The event that happens when the switch is flipped.
boundsElementBoundsThe bounds of the element.
sizedoubleThe size of the switch. (Default: 30)
paddingdoubleThe 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
ctxStaticContextThe context of the components.
surfaceImageSurfaceThe 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
apiICoreClientAPIThe client API
argsKeyEventThe 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
apiICoreClientAPIThe Client API
argsMouseEventThe mouse event args.
RenderInteractiveElements(float)
Renders the element as an interactive element.
public override void RenderInteractiveElements(float deltaTime)
Parameters
deltaTimefloatThe change in time.
SetValue(bool)
Sets the value of the switch on or off.
public void SetValue(bool on)
Parameters
onboolon == true.