How can I reinitialize the event handler
ducasse at iam.unibe.ch
Sun Apr 7 17:59:05 UTC 2002
I will retry my experience but what I noticed is that when I was adding
handleMouseOver: and mouseEnter mouseLeave if I had previously a morph form
the class it would not react and I had to recreate an instance t=of the
class. There is in this case the event would work.
> On Sunday 07 April 2002 04:15 am, ducasse wrote:
>> Now I want to do it for Morphs. This works well except for events.
> Which events?
>> Apparently the event handler is created once at initialization time and
>> after even if we compile new method dealing with event like handles...
>> they are not taken into account.
> The typical handler code (in Morph) for events looks like this:
> mouseDown: evt
> self eventHandler ifNotNil:
> [self eventHandler mouseDown: evt fromMorph: self].
> If you define a new mouseDown: method it will be used.
I know but I have the impression that the eventHandler is created at
initialisation time, then compiling a new method would not take effect for
previously created objects.
>> This is not a problem for normal
>> programming but for my purpose I would like to know if there is a method
>> that I can invoke manually from within an inspector that would reset the
>> event handler. Just to show that I do not have to create another instance
>> to test the new behavior.
> Also, even if you use the event handler, you can do this. For instance, in
> your initialization (or elsewhere) you can say:
> self on: #mouseDown send: #mouseDownEvent:morph: to: self
> and then when the event occurs you will be sent the event and the morph to
> that method.
> You can later redefine #mouseDownEvent:morph: at will and see the new
More information about the Squeak-dev