Class GuiElementToggleButton
- Namespace
- Vintagestory.API.Client
- Assembly
- VintagestoryAPI.dll
Creates a toggle button for the GUI. Open in GitHub
public class GuiElementToggleButton : GuiElementTextBase, IDisposable
- Inheritance
-
GuiElementToggleButton
- Implements
- Inherited Members
- Extension Methods
Constructors
GuiElementToggleButton(ICoreClientAPI, string, string, CairoFont, Action<bool>, ElementBounds, bool)
Constructor for the button
public GuiElementToggleButton(ICoreClientAPI capi, string icon, string text, CairoFont font, Action<bool> OnToggled, ElementBounds bounds, bool toggleable = false)
Parameters
capiICoreClientAPIThe core client API.
iconstringThe icon name
textstringThe text for the button.
fontCairoFontThe font of the text.
OnToggledAction<bool>The action that happens when the button is toggled.
boundsElementBoundsThe bounding box of the button.
toggleableboolCan the button be toggled on or off?
Fields
On
Is this button on?
public bool On
Field Value
Toggleable
Is this button toggleable?
public bool Toggleable
Field Value
Properties
Focusable
Is this element capable of being in the focus?
public override bool Focusable { get; }
Property Value
Methods
ComposeElements(Context, ImageSurface)
Composes the element in both the pressed, and released states.
public override void ComposeElements(Context ctx, ImageSurface surface)
Parameters
ctxContextThe context of the element.
surfaceImageSurfaceThe surface of the element.
Remarks
Neither the context, nor the surface is used in this function.
Dispose()
Disposes of the button.
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)
Handles the mouse button press while the mouse is on this button.
public override void OnMouseDownOnElement(ICoreClientAPI api, MouseEvent args)
Parameters
apiICoreClientAPIThe client API
argsMouseEventThe mouse event arguments.
OnMouseUp(ICoreClientAPI, MouseEvent)
Handles the event fired when the mouse is released.
public override void OnMouseUp(ICoreClientAPI api, MouseEvent args)
Parameters
apiICoreClientAPIThe client API
argsMouseEventMouse event arguments
OnMouseUpOnElement(ICoreClientAPI, MouseEvent)
Handles the mouse button release while the mouse is on this button.
public override void OnMouseUpOnElement(ICoreClientAPI api, MouseEvent args)
Parameters
apiICoreClientAPIThe client API
argsMouseEventThe mouse event arguments
RenderInteractiveElements(float)
Renders the button.
public override void RenderInteractiveElements(float deltaTime)
Parameters
deltaTimefloatThe time elapsed.
SetValue(bool)
Sets the value of the button.
public void SetValue(bool on)
Parameters
onboolAm I on or off?