Skip to content
This repository was archived by the owner on Jun 14, 2021. It is now read-only.
Steve Ruiz edited this page Feb 3, 2018 · 2 revisions

A toggle has two states, on and off, and has two buttons for selecting the state.


Constructor

myToggle = new Toggle
    #options: ['Off', 'On']
    #icon: false
    #toggled: false

Properties

toggle.options <array>

The toggle's two button labels, provided as an array of two strings. The toggle will use the strings as labels for the toggle's on and off buttons. Generally speaking, the more affirmative option should be the second string. Constructor only.

myToggle = new Toggle
    options: ['Inactive', 'Active']

toggle.icon <boolean>

Whether to use the strings provided in options as icon names, rather than text labels. If set to true, the Toggle will show (or attempt to show) icons using the options strings provided. Constructor only.

myToggle = new Toggle
    options: ['pizza', 'apple']
    icon: true

toggle.toggled <bool>

Whether the toggle should be toggled or not. If true, the right-hand button will be active. If false, the left-hand button will be active.

myToggle = new Toggle
    toggled: true

myToggle.toggled = false

myToggle.on "change:toggled", (value) -> 
    print "Is toggle toggled? " + value
Clone this wiki locally