[squeak-dev] ActiveEvent/Object>>currentEvent broken by Morphic-mt.1283?

tim Rowledge tim at rowledge.org
Sat Aug 20 22:52:48 UTC 2016


All good points Marcel -

> On 20-08-2016, at 3:28 AM, marcel.taeumel <Marcel.Taeumel at hpi.de> wrote:
> 
>> 
>> that code is tricky in the sense that it is exactly like MVC's "[Sensor
>> anyButtonPressed]" loops but you should favor Morphic's event dispatching
>> style.

Absolutely; I’d love to get around to rewriting all that stuff but it isn’t going to happen soon. There’s 24 usages of currentEvent in Scratch code. Oh, and at least 10 in the base image code, so I hope you’ve been able to convince yourself they won’t have similar problems!

I used currentEvent on Bert’s advice a couple of years ago and understood that it really should be the current event. If that is no longer true then I see a good chance of quite a few bits of code going wrong and it needs to be trapped to alert people  properly. I’m fairly sure that my original puzzling situation was being caused by new events getting read as part of the doOneCycle, some of them causing changes in the PaintCanvas state and thus running clearMoveState  which nils my selectionRect and thus, Boom. But your changes leave the currentEvent returning the same event (I think) all the time or at least nearly so.

At a wild guess the entire edifice around ActiveEvent and #currentEvent etc are relics of converting to events and ought to be removed in order to force us all to use proper event handling!



>> 
>> I noticed that the selection tool in the Paint Editor does not work at
>> all. And the nil-debugger appears *only* if I try to draw a rectangle
>> after trying to select something, which did not work.

Correct. Reverting the two #sendFocus… methods lets it all work. 

>> 
>> So, does the selection tool work for you? I would fix that first.

It only works when reverting etc.

>> My guess is that Scratch can be fixed to work again.


I certainly hope so ;-) You’ll have a large number of kids chasing you to the ends of the earth if not!


> At this point in the code, "self currentEvent" would always be the same
> event object in the middle of event dispatching. So will "currentHand".
> Hence, this whileTrue will never end if you ask the same (immutable) event
> object over and over again. You nil-bug occures if you ivoke another event
> inside this loop, which will then call some code in PaintCanvas that makes
> selectionRect nil. 

Yeah, I think this where the old rule - self current will always be the latest event to have been processed - has been broken. 

But yes, the best real answer is to rewrite a couple of dozen complex UI methods. Sigh.


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Don't diddle code to make it faster; find a better algorithm.




More information about the Squeak-dev mailing list