lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Is necessary to call the parent constructor?
Well, I think so. I send only an example. the true code is a window built with IUP. In the next example, if I want to create a Window descendant class, I need to call the anscestor construtor.

require('iuplua')
require('iupluacontrols')

class = require('pl.class')

class.control(class.properties)

function control:bind(control, event, callback)
control[event] = function (control)
callback()
end
end

class.window(control)

function window:_init(title)
self.dialog = iup.dialog{title = title, size = 'THRIDxHALF', gap = 5}
self._container = iup.vbox{}
end

function window:show()
self.dialog:showxy(iup.CENTER, iup.CENTER)
end

function window:run()
iup.MainLoop()
end

function window:set_container(data)
local hbox = iup.hbox{border = 'NO'}

for _, v in ipairs(data) do
if type(v) == 'table' then
for _, c in ipairs(v) do
iup.Append(hbox, c)
iup.Append(self._container, hbox)
end
else
iup.Append(hbox, v)
iup.Append(self._container, hbox)
end
end
iup.Append(self.dialog, self._container)
end


The code could continue as_

class.customwindow(window)

function customwindow:_init(title)
self:super(title)
-- Some customized code
end




Em 03-01-2013 07:13, Vadim Peretokin escreveu:
Is it necessary to make that happen?