Toggle Button
Check out the standard help for an overview of the toggle button.
API Examples
// Internally the component is known as "toggle_button" var toggle_buttonComponent1 = findComponent("My Page", "toggle_button", "MyToggleButton"); // To retrieve a toggle_button component called "MyToggleButton" on a page called "My Page" var toggle_buttonComponent2 = findComponentInForeground("My Foreground", "toggle_button", "MyToggleButton"); // To retrieve a toggle_button component in the foreground. var toggle_buttonComponent3 = createComponent(parentComponent, "toggle_button", 0, 0, 100, 100); // to create a toggle_button component inside a custom component. // Retrieving a property var textOnToggleButton = getProperty(toggle_buttonComponent1, "text"); console.log(textOnToggleButton); // Setting a property setProperty(toggle_buttonComponent1, "text", "on"); setProperty(toggle_buttonComponent1, "toggled_text", "off");
Properties
See the shared property list for all properties available for this component.
Property | Type | Description |
---|---|---|
text | string | The text of normal status |
toggled_text | string | The text of toggled status |
hide_text | bool | Hide / show the text |
keep_aspect_ratio_mode | bool | Default is false. |
default_filename | string | The image of normal status |
down_filename | string | The image when pressed |
disabled_filename | string | The image of disabled status |
slice_top, slice_bottom slice_left, slice_right | number | Used to preserve the edges of an image when resizing. To quickly find optimal slice values, place a component using the editor and choose ‘Edit Values’. |
icon_filename | string | The filename of icon. |
icon_scale | number | Scales the icon based on native size of the icon. |
font_filename | string | The filename of a font inside the /fonts folder (e.g vera.ttf). If the font isn’t found the text will disappear. |
font_size | number | The size of the font. Decimal values are allowed. |
toggled_font_filename | string | The filename of a font inside the /fonts folder (e.g vera.ttf). If the font isn’t found the text will disappear. |
toggled_font_size | number | The size of the font. Decimal values are allowed. |
tracking | number | Distance between characters. |
toggled_tracking | number | Distance between characters. |
scale_border_with_screen | bool | Proportionally scales the sides, edges and corners of the nine slice image that are set in the editable values of the image used as a base for the component if it is true. |
text_scaling | string | Scales the text. |
caption_x_pos | real | The x position of the text |
caption_y_pos | real | The y position of the text |
icon_x_pos | real | The x position of the icon |
icon_y_pos | real | The y position of the icon |
font_align | number | |
enabled | bool | Enable / Disable |
toggled | bool | Normal / Toggled |
toggled_default_filename | string | The image of toggled status |
toggled_down_filename | string | The image when pressed |
toggled_disabled_filename | string | The image of disable status |
Events
See the shared event list for all events available for this component.
Event | Params | Description |
---|---|---|
on_activated | called when set it activated | |
on_deactivated | called when set it deactivated |