This event is particularly interesting when you want to initialize its properties.
Window:onCreate() event
This event is fired when the Window object has just been created, just after the Window:constructor() call.
Return value
The event returns no value.Example
local ui = require "ui"
-- create a personalized template Window Object
local MyWindow = Object(ui.Window)
-- define a custom constructor for MyWindow
function MyWindow:constructor(title)
ui.Window.constructor(self, title or "MyWindow template", "fixed", 640, 480)
end
-- defines the MyWindow widgets, menus and status bar
function MyWindow:onCreate()
self:status("Welcome on MyWindow !")
self.menu = ui.Menu("&File", "&Edit", "&About")
self.editor = ui.Edit(self, "")
self.editor.align = "all"
end
-- Align the self.editor widget when resizing MyWindow
function MyWindow:onResize()
self.editor.align = "all"
end
-- creates two templated MyWindow
local win = MyWindow("Template 1")
local win2 = MyWindow("Template 2")
win:show()
win2:show()
while win.visible or win2.visible do
ui.update()
end