I hate this code :)
I remember that in the EventModel we had to store the previous event somehow
but this was one year ago.
I should go back to the code one of these days.
So for now I say make Phrath working we will check the kernel later.
Stef
> But as far as I can see, that "if key <space> pressed?" cannot be event
> driven, because we don't want to start execution at that block if the space
> key is pressed, rather we want that to evaluate to true if the space key has
> been pressed recently ("recently" seems a problematic term to use here but
> that's another issue!).
>
> Here's the code I started throwing together to make this work -- see the bit
> following this line:
> type = EventTypeKeyboard
>
> InputEventSensor>>processEvent: evt
> "Process a single event. This method is run at high priority.
>
> The event record is:
> <type><timestamp><character code><updown><modifier keys>...
> where updown is:
> 0 - keystroke
> 1 - key down
> 2 - key up
>
> NOTE: You must ensure that there is an instance variable keyPressed."
>
> | type updown |
>
> type := evt at: 1.
>
> "Treat menu events first"
> type = EventTypeMenu
> ifTrue: [
> self processMenuEvent: evt.
> ^nil].
>
> "Tackle mouse events first"
> type = EventTypeMouse
> ifTrue: [
> "Transmogrify the button state according to the
> platform's button map definition"
> evt at: 5 put: (ButtonDecodeTable at: (evt at: 5) + 1).
> "Map the mouse buttons depending on modifiers"
> evt at: 5 put: (self mapButtons: (evt at: 5) modifiers:
> (evt at: 6)).
>
> "Update state for polling calls"
> mousePosition := (evt at: 3) @ (evt at: 4).
> modifiers := evt at: 6.
> mouseButtons := evt at: 5.
>
> ^evt].
>
>
> "Finally keyboard"
> type = EventTypeKeyboard
> ifTrue: [
> "Update state for polling calls"
> modifiers := evt at: 5.
> updown := evt at: 4.
> (updown = 2) ifTrue: [
> keyPressed := nil
> ] ifFalse: [
> keyPressed := evt at: 3 ].
> ^evt].
>
> "Handle all events other than Keyborad or Mouse."
> ^evt.
>
> Then I use this:
>
> InputEventSensor>>keyPressed: asciiValue
> "Is this key being pressed?"
> self nextEvent.
> ^keyPressed = asciiValue
>
> So should I be doing this? Should I test out these changes and suggest a
> patch to Pharo? I'm happy that the answer might be "no", but what can I try
> instead?
>
> Thanks for your help.
> -Eric.
>
>
> --
> Eric Clack
> [email protected]
> East Sussex, England.