This event is particularly interesting when you want to initialize its properties.
Canvas:onCreate() event
This event is fired when the Canvas object has just been created (just after the Canvas:constructor() call).
Return value
The event returns no value.Example
local ui = require "ui"
require "canvas"
-- creates a simple window
local win = ui.Window("Canvas:onCreate() event sample", 640, 400)
local Canvas = ui.Canvas(win, 320, 200)
-- Canvas:onCreate() event to center and draw text on the Canvas widget
function Canvas:onCreate()
Canvas:center()
Canvas:clear(0x000000FF)
Canvas:print("Hello LuaRT !", 130, 100, 0xFFA300FF)
Canvas:flip()
end
win:show()
-- update the ui
while win.visible do
ui.update()
end