DWT event handling
Frank Benoit
keinfarbton at googlemail.com
Sun May 18 11:04:48 PDT 2008
Lester L. Martin II schrieb:
> my code is more simple
>
> class listen: Listener
> {
> void delegate(Event e) func_;
>
> this(void delegate(Event e) func = null)
> {
> if(func !is null)
> func_ = func;
> else
> func_ = &this.genericHandle;
> }
>
> public void handleEvent(Event e)
> {
> func_(e);
> }
>
> public void genericHandle(Event e)
> {
> Stdout("Event Accepted.").newline.flush;
> }
> }
>
> (user is a declared DWT variable)
>
> user.addListener(new listen(&dg));
>
> (this is a function inside a class)
>
> private void dg(Event E)
> {
> //handle event here
> }
>
I think this is just less flexible.
This simple case would be:
user.addListener(dgListener(&dg));
private void dg(Event E)
{
//handle event here
}
It is the same. But the template can handle _optional_ arguments that
are stored in a generated template class.
Well actually there is no default-handler. But i do not understand what
is the use of that. If you do not want a handler, why register a dummy one?
More information about the Digitalmars-d-dwt
mailing list