Skip to main content

Add a switch (:add_switch)

Declaration

dialog_obj = dialog_obj:add_switch(label [, default_on])

Parameters

  • label
    String. The label text shown on the left of the switch
  • default_on
    Boolean, optional. Default state, default false (off)

Returns

  • dialog_obj
    Dialog. Returns the dialog itself
  • :show() return type
    Boolean. Whether the switch is on

Description

Add a switch to the dialog

Example

local c, s = dialog():add_switch('A switch', false):show()
sys.alert(s['A switch'])

Note: Uses function outside this chapter sys.alert

Full example

See :show()