The Canvas.visible property is also affected by the Canvas:show() and Canvas:hide() methods.
Canvas.visible read/write property
Get or set the Canvas visibility on screen, a true value means that the Canvas is shown, a false value means that the Canvas is hidden.
Example
local ui = require "ui"
require "canvas"
-- create a simple Canvas
local win = ui.Window("Canvas.visible sample", "fixed", 640, 480)
local Canvas = ui.Canvas(win, 0, 50, 640, 430)
Canvas.fontsize = 30
function Canvas:onPaint()
self:begin()
self:clear()
self:print("Hello", math.random(0,630), math.random(0, 390), math.random(0xFFFFFFFF))
self:flip()
end
local button = ui.Button(win, "Hide the Canvas widget")
button:center()
button.y = 10
function button:onClick()
Canvas.visible = not Canvas.visible
button.text = (Canvas.visible and "Hide" or "Show").. " the Canvas widget"
end
ui.run(win):wait()