Skip to main content

Show Toast (sys.toast)

Declaration

sys.toast(text [, orientation ])

Parameters

  • text
    String. The message to display.
  • orientation
    Integer, optional. Screen orientation. Defaults to the last orientation set by screen.init.
    0 = portrait (Home at bottom)
    1 = landscape (Home at right)
    2 = landscape (Home at left)
    3 = portrait (Home at top)
    -1 = hide toast immediately

Notes

Displays a toast message at the bottom of the screen in the current rotated coordinate system.
This function is asynchronous. The toast is shown for a total of 2.8 seconds and does not block taps.
On iOS 13.2+, it does not affect color picking.

Example

-- Show a toast
sys.toast("Hello world decisively")

Example

-- Show current date & time in real time
while (true) do
sys.toast("Long press volume key to stop by default\n\n"..os.date("%Y-%m-%d %H:%M:%S"), device.front_orien())
sys.msleep(1000)
end

Note: The above uses functions outside this chapter: device.front_orien, os.date