This event is particularly interesting when you want to initialize its properties.
Edit:onCreate() event
This event is fired when the Edit object has just been created (just after the Edit:constructor() call).
Return value
The event returns no value.Example
local ui = require "ui"
Lorem = Object(ui.Edit)
-- Lorem:onCreate event to set the Lorem properties after creation
function Lorem:onCreate()
self.font = "Times New Roman"
self.fontsize = 10
self.wordwrap = true
self.text = [[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.]]
end
-- creates a simple window
local win = ui.Window("Edit:onCreate() event sample", 340, 230)
local label = ui.Label(win, "Enter text : ", 10, 10)
Lorem(win, "", label.x + label.width + 4, label.y)
win:show()
-- update Edit.text at each second
while win.visible do
ui.update()
end