[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Penlight - Calling the constructor of a parent class
- From: Luciano de Souza <luchyanus@...>
- Date: Thu, 03 Jan 2013 11:13:46 -0200
I don't know if I understood what you mean. The Penlight manual
recommends "self:super(title". With the following code, I get an error
since the global "super" does not exist:
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
class.custom(window)
function custom:_init(title)
super(self, '_init')
end
custom = custom('Test')
custom:show()
custom:run()
Em 03-01-2013 07:10, Xavier Wang escreveu:
2013/1/3 steve donovan<steve.j.donovan@gmail.com>:
It's hard to change the meaning of obj.m without fooling with its
metatable, or doing nasty things like actually poking the method into
obj itself.
So, do we have any way to make this shortcut work?
or something else like:
super(self) "_init" (title)
?
--
regards,
Xavier Wang.