Signals and Slots in D
Fredrik Olsson
peylow at gmail.com
Fri Sep 29 02:24:01 PDT 2006
Walter Bright skrev:
<snip>
>> For the signal targets it will be impossible to tell a click from a
>> double click. Unless you pass a more arguments, but then you kind of
>> loose the simple idea of connecting to listen to a single event signal.
>
> Ok, I see. The solution is straightforward:
>
> class MyControl {
> mixin Signal!(MouseButton) Click;
> mixin Signal!(MouseButton) DoubleClick;
>
> void myActualClick(MouseButton mb) {
> ...
> Click.emit(mb);
> }
>
> void myActualDoubleClick(MouseButton mb) {
> ...
> DoubleClick.emit(mb);
> }
> }
>
> You can have any number of signals in a class.
I just must say I love the beauty of this. Simple, no magic added, and
high readability. What more can anyone ask for?
// Fredrik Olsson
More information about the Digitalmars-d
mailing list