Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, and Errors
   Dialogs, Clipboard, Platform, and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Collections
    array
    map
    data_array
   Image data
   Image stream
   Dialogs
    fileopen
    filesave
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:objects:gui_togglebutton

togglebutton

`togglebutton()` creates a checkable button.

Constructor

togglebutton()

Creates a toggle button object.

t = togglebutton().text("Enabled").checked(true);

Common Component Methods

Most visible GUI controls support these methods:

Method Returns Description
`position(x, y)` self Sets the component position in pixels.
`size(width, height)` self Sets component size in pixels. Width and height are clamped to at least 1.
`visible(enabled)` self Shows or hides the component.
`enabled(enabled)` self Enables or disables user interaction.

Common component properties:

Property Type Description
`position_x` number Current x position.
`position_y` number Current y position.
`size_width` number Current width.
`size_height` number Current height.
`visible` boolean Current visible state.
`enabled` boolean Current enabled state.

Methods

Method Returns Description
`text(value)` self Sets button text.
`checked(enabled)` self Sets checked state.
`on_change(callback)` self Sets callback called when checked state changes.
`on_click(callback)` self Sets callback called when clicked.
`click()` boolean Simulates a click.

Example

function changed()
{
    print("changed");
}
 
t = togglebutton().position(20, 20).size(160, 24).text("Use probing").on_change(changed);
window().title("Toggle").size(220, 100).add(t).show();

Previous: drawablebutton

Next: togglegroup

exprv4/reference/objects/gui_togglebutton.txt · Last modified: (external edit)

Page Tools