lua-users home
lua-l archive

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


[Note: I only use VCL in CBuilder, so you might have to translate this mail
a bit to apply it to Delphi.]

Apart from properties and methods you might also want to consider events.
An event is basically a property that takes a closure value.  Many controls
use events to trigger actions.  Buttons and such generate OnClick events and
so on.  These events are *not* directly wired to virtual methods but are
handled by a double dispatch scheme.

For example, a button control double dispatches a click to its OnClick event
and passes itself as the single argument.  The OnClick closure can have a
very generic implementation (i.e. not depending on specific control types
and instances) because the originator will be available as an explicit
argument.  Typically you could just forward the click event to Lua and pass
the originator as a light userdata.  The good news is that you can wire
events at run time!

HTH

--
Wim