Hi eric

> Hi all, 
> I've been working on Phratch, a port of MIT Scratch to Pharo, mostly to learn 
> Smalltalk and also because Scratch is a great learning environment and I 
> can't bear to see it end up in Flash.
> 
> So I've been digging about in the old code to fix bugs and I'm getting a 
> sense that there's some conflict between the way the Scratch team got things 
> working in Squeak, and the way the Pharo team things want things done. 
> 
> I must say I think the Pharo team have things right in their drive for a 
> cleaner, simpler system, however that means I'm a bit stuck.
> 
> See the attached image of my Scratch script.
> 
> Here's where I am...
> 1. Keyboard events for 'When <key> pressed' HatBlockMorph (with then pen 
> commands) work fine as these follow the regular Morphic event model
> 2. But 'if <key> pressed' operation (with the stamp command inside) doesn't 
> work because it relies on polling the InputEventSensor, and I think this bit 
> of this class doesn't work as I expect.
> 
> My view right now is that for 2, I need to use some kind of polling, and 
> InputEventSensor has methods such as keyboardPeek and peekKeyboardEvent that 
> imply you can poll,

Why do you need to poll for event? 
In Pharo 30 we should integrate a fix and normally you can just register to get 
notified when a new event is happening.

May be have a look at the EventModel package 

http://www.squeaksource.com/EventModel/
I hope it gets the latest version of the code. Fernando used it in gaucho so 
soon it will be in Pharo3.0 but we should do another serious pass on it.


> but looking at the implementation, which uses WaitfreeQueue I can see that 
> calling these methods results in events being consumed, hence my post to 
> Stack Overflow...
> http://stackoverflow.com/questions/16395418/cant-peek-keyboard-events-multiple-times-in-smalltalk-pharo-2
> 
> I've hacked around to come up with something that sort of works, outlined in 
> this post:
> http://stackoverflow.com/questions/16495436/saving-modifications-to-existing-kernel-methods-to-monticello
> ...but I get the feeling I'm doing the wrong thing here, and that I should 
> come up with a solution that better fits the 'Pharo way'.
> 
> So, let me know what you think. I'm happy to provide more info and to 
> research better solutions, let me know...
> 
> Finally, apologies for the long post! 
> 
> Best regards, 
> -Eric.
> 
> -- 
> Eric Clack
> ericcl...@googlemail.com
> East Sussex, England.
> <keypress.gif>

Reply via email to