Button:onCreate() event


This event is fired when the Button object has just been created (just after the Button:constructor() call).

This event is particularly interesting when you want to initialize its properties.

Return value

The event returns no value.

Example

local ui = require "ui" -- creates a simple window local win = ui.Window("Button:onCreate() event sample", 320, 200) local button = ui.Button(win, tostring(sys.Datetime().date), 80, 60) -- Label:onCreate event to set the font properties function button:onCreate() self.font = "Times" self.fontsize = "24" self.fontstyle = { bold = true } end function button:onClick() -- create a float window... local windate = ui.Window("Choose a date :", "float", 220,150) -- with a Calendar widget windate.width = cal.width windate.height = cal.height cal.align = "all" -- put the window next to mouse position windate.x, windate.y = ui.mousepos() local done = false win:showmodal(windate) -- Calendar onClick event : set the button text with the choosen date function cal:onClick(value) button.text = value.date windate:hide() end -- update until user choosed a date while windate.visible do ui.update() end end win:show() -- update Label.text at each second while win.visible do ui.update() end