Toggle Button


Object Preview
Enable Background Music
Developer Edition Object

The Toggle Button object provides a sleek, modern on/off switch directly inside your Custom Launcher. It is the perfect interface element for handling user preferences, settings menus, and binary choices that require immediate visual feedback.

Whether you are allowing users to enable background music, toggle high-resolution textures, or opt into auto-login, the Toggle Button handles the interaction smoothly. When paired with events, this simple switch becomes a powerful trigger for your Custom Game Launcher logic.

Pro Tip

The Toggle Button object requires the Developer Edition. It is designed to empower complex settings menus and variable-driven logic states.

Toggle Button Overview

A Toggle Button acts as a visual representation of a true/false state. Users can click the track or the knob to flip the switch. The visual styling of the object is fully customizable, from the background color of the active and inactive states to the color of the sliding knob itself.

Typical Uses

  • Creating interactive settings menus
  • Turning launcher background music on or off
  • Enabling or disabling specific game mods
  • Toggling auto-login or remember me functions

Default Settings

When dropped onto your page, the Toggle Button applies a clean, modern styling configuration by default.

Property Default Value
Dimensions Width: 60, Height: 30
Default State Off (false)
"On" Color #1e88e5
"Off" Color #555555
Knob Color #ffffff

Properties

The visual editor allows you to shape the state and appearance of the Toggle Button seamlessly.

Default State

  • On by Default: Determine whether the toggle starts in the "On" state when the launcher loads. If unchecked, it will default to "Off".

Colors

  • "On" Color: Set the background color of the switch track when the object is toggled on.
  • "Off" Color: Set the background color of the switch track when the object is toggled off.
  • Knob Color: Choose the color of the sliding circular handle inside the switch.

Toggle Button Events

To make the Toggle Button interactive and functional, you can wire logic into its dedicated events.

onToggleOn

Fires exclusively when the toggle button is switched to the ON position. Use this to enable features, display content, or trigger conditional actions like checking an "auto-login" preference.

onToggleOff

Fires exclusively when the toggle button is switched to the OFF position. Use this to disable features, hide elements, mute music, or revert actions.

onToggle

Fires on any state change (either ON or OFF). This is highly useful when you want a single event to dynamically react to the new state, such as pushing the current property into a variable every time it is clicked.

Supported Actions

While there are no specific actions strictly targeted only at the Toggle Button, it fully supports global object manipulation actions. This allows your launcher to dynamically alter the toggle based on other logic.

Action How it interacts
Show / Hide Objects Dynamically reveal or conceal the Toggle Button in advanced settings menus.
Set Object Property from Variable Programmatically change the state of the toggle by targeting its toggled property with a variable (e.g., loaded from a save file).

Building Logic with the Toggle Button

The core strength of the Toggle Button is its ability to trigger two distinct pathways of logic based on its visual state.

Example 1: Audio Control

Give users an easy way to mute and unmute your launcher's background ambiance.

  1. Add a Toggle Button to your settings page.
  2. Under the onToggleOn event, assign the Play Sound action and link your ambient music track. Ensure 'Loop Sound' is checked.
  3. Under the onToggleOff event, assign the Mute Music action. Now the user has full control over the audio environment.

Example 2: Persistent User Settings

Save the user's preference so the launcher remembers their choice the next time it opens.

  1. Use the onToggle event (which fires on any change).
  2. Assign a Push to Variable action to read the Toggle Button's toggled property and store it in a global variable (e.g., var_music_enabled).
  3. Follow it up with a Set INI Value from Variable or Save Variable to File action. When the launcher loads again next time, you can read this file and use Set Object Property from Variable to restore the correct switch state visually!

Custom CSS Example

Available exclusively in the Developer Edition, you can use Custom CSS to bypass the standard colors entirely, applying stunning gradients and glass effects that work flawlessly regardless of the underlying properties panel logic.

Custom CSS Neon Glass Preview
Visual Effects

Pro Tip

This live preview demonstrates how static gradients and box shadows create a premium look. Because it doesn't rely on the engine's state attributes to define its colors, this CSS works perfectly inside the editor and live launcher alike!

css

/* Developer Edition Custom CSS Example for Toggle Button */
/* No manual object scoping needed */
background: rgba(255,255,255,.08) !important;
border: 1px solid rgba(0,229,255,.25) !important;
box-shadow: inset 0 0 10px rgba(0,229,255,.15) !important;
backdrop-filter: blur(5px) !important;
transition: background .25s ease, box-shadow .25s ease !important;
.glcv4-toggle-knob {
 background: radial-gradient(circle at 30% 30%, #fff, #b8ffff) !important;
 box-shadow: 0 0 10px rgba(0,229,255,.45) !important;
 transition: transform .25s ease, box-shadow .25s ease !important;
}
:hover { 
 box-shadow: inset 0 0 12px rgba(0,229,255,.25) !important; 
}
:hover .glcv4-toggle-knob { 
 transform: scale(1.1) !important; 
 box-shadow: 0 0 14px rgba(0,229,255,.6) !important; 
}

Summary

The Toggle Button is a highly intuitive, elegant component designed for handling binary user preferences inside your Custom Game Launcher. With dedicated events for on and off states, you can rapidly prototype settings menus, audio controls, and logic flags that directly influence the player's experience.