This event is particularly interesting when you want to initialize its properties.
Checkbox:onCreate() event
This event is fired when the Checkbox object has just been created (just after the Checkbox:constructor() call).
Return value
The event returns no value.Example
local ui = require "ui"
-- create a custom widget from a Checkbox
local LinkCheckbox = Object(ui.Checkbox)
function LinkCheckbox:onCreate()
self.cursor = "hand"
end
-- sets the onHover event
function LinkCheckbox:onHover()
self.fontstyle = { underline = true }
end
-- sets the onLeave event
function LinkCheckbox:onLeave()
self.fontstyle = { underline = false }
end
-- create a window
local win = ui.Window("Label:onLeave() sample", 320, 200)
--create a LinkCheckbox object
local checkbox = LinkCheckbox(win, "Click Me !", 120, 75)
function checkbox:onClick()
win:status("LinkCheckbox is "..(self.checked and "checked" or "unchecked"))
end
checkbox:onClick()
ui.run(win):wait()