[Vm-dev] Re: [squeak-dev] Oddities with #keyDown and Sensor
Lawson English
lenglish5 at cox.net
Fri Sep 23 23:49:59 UTC 2011
[This is a duplicate of what was sent in reply to the Dev list. It may
be an image problem and it may be a VM problem so I'm sending to both
places]
On 9/23/11 1:59 PM, Bert Freudenberg wrote:
> On 23.09.2011, at 12:15, Lawson English wrote:
> [...]
>>
>> Obviously, I'm doing something fundamentally wrong
> Yes. Do Not Use Sensor Directly From Morphic Code. Otherwise you get
> unpredictable behavior because the Morphic main loop also fetches
> events from Sensor.
>
> That said, keyboard events are indeed inconsistent across platforms,
> and you have to make do with whatever the particular platform offers.
> Be sure to look at both the 8-bit char code (evtBuf at: 3) and the 32
> bit unicode (evtBuf at: 6) - some keys may be reported only in one of
> the two places. A good strategy is to look at (evtBuf at: 6) and if it
> is 0 use (evtBuf at: 3).
>
> Note that on the Mac, keydown/up events use different codes than
> stroke events.
>
> - Bert -
>
>
That's the thing. Here are the variables from doing "evt inspect" from
within #keyDown: and #keyStroke. Notice that the keyValue info is
missing, period, from the event passed into #keyDown: That is why I was
trying to "roll my own". Linux doesn't have this problem, but the Mac
does. I beat my head against this wall all night, stepping through the
debugger trying to find out where things went wrong.
timeStamp: 379995
source: a HandMorph(3216)
type: #keystroke
buttons: 0
position: 114 at 237
handler: nil
wasHandled: true
keyValue: 102
timeStamp: 379995
source: a HandMorph(3216)
type: #keyDown
buttons: 0
position: 114 at 237
handler: nil
wasHandled: true
keyValue: 0
More information about the Vm-dev
mailing list