Skip to main content

Button

See the ButtonDemo class.

void DrawButtons()
{
// An empty button that draws nothing except for the button itself.
// Returns true when pressed.
if (Gui.Button())
Logger.Debug("Pressed");

if (Gui.TextButton("Button"))
Logger.Debug("Pressed");

// Set the padding of the Button within the scope.
using (Style.Button.BeginPadding(new(2, 2, 2, 2)))
{
if (Gui.NextWidthHeight(30f, 30f).SpriteButton(Properties.SampleSprite))
Logger.Debug("Pressed");
}

// Begin the button scope.
using (Gui.BeginButton())
{
Gui.Text("0");
Gui.Text("1");
Gui.Text("2");
}
}

void DrawRadioButtons()
{
Gui.RadioButton(ref isOnRadioButton1);

Gui.NextWidthHeight(40f, 40f).RadioButton(ref isOnRadioButton2);

// Draw radio buttons horizontally.
using (Ctx.Horizontal())
direction = Gui.RadioButtons(direction);
}

void DrawToggleButtons()
{
if (Gui.ToggleButton(ref isSelected1))
{
Logger.Debug("Pressed");
}

using (Gui.BeginToggleButton(isSelected2))
{
Gui.Text("0");
Gui.Text("1");
Gui.Text("2");
}
// Determine whether it is selected through Context.
isSelected2 = Ctx.IsLastSelected();

Gui.ToggleTextButton("ToggleTextButton", ref isSelected3);
}