On 31 August 2012 21:21, Igor Stasenko <[email protected]> wrote:
> and to give an idea, how current Morphic doing that, a starting point is
> MorphicEventDispatcher
>
> personally, i find this code too complex to understand, given heavy
> use of case statements and branches.
>
> But i figured out, that this method:
>
>
> dispatchEvent: anEvent with: aMorph
>         "Dispatch the given event for a morph that has chosen the receiver to
> dispatch its events. The method implements a shortcut for repeated
> dispatches of events using the same dispatcher."
>         anEvent type == lastType ifTrue:[^self perform: lastDispatch with:
> anEvent with: aMorph].
>         "Otherwise classify"
>         lastType := anEvent type.
>         anEvent isMouse ifTrue:[
>                 anEvent isMouseDown ifTrue:[
>                         lastDispatch := #dispatchMouseDown:with:.
>                         ^self dispatchMouseDown: anEvent with: aMorph]].
>         anEvent type == #dropEvent ifTrue:[
>                 lastDispatch := #dispatchDropEvent:with:.
>                 ^self dispatchDropEvent: anEvent with: aMorph].
>         anEvent isWindowEvent ifTrue:[
>                 lastDispatch := #dispatchWindowEvent:with:.
>                 ^self dispatchWindowEvent: anEvent with: aMorph].
>         lastDispatch := #dispatchDefault:with:.
>         ^self dispatchDefault: anEvent with: aMorph
>
> ---
>
> actually can be replaced by one-liner:
>
> dispatchEvent: anEvent with: aMorph
>     morph := aMorph.
>    ^ anEvent sentTo: self

oh.. it is two lines, sorry..

> .. yeah.. my favorite thing:  double-dispatch.
>
> --
> Best regards,
> Igor Stasenko.



-- 
Best regards,
Igor Stasenko.

Reply via email to