[squeak-dev] Fun with KeyPressMorph
digit at sonic.net
Thu Nov 8 06:39:40 UTC 2018
I found KeyPressMorph today and opened one up (using World menu->New morph...->From alphabetical list->K-M->KeyPressMorph).
It seems to be listening for all keyboard & mouse events from a Hand, but yet only displays characters if I have clicked inside the white box first. (Clicking inside its white box brings up a balloon which jitters quite badly.)
At first, I was surprised that the white box would show the 'f' key as 'enter', right shift as '<', etc.
But then I started having even more fun after placing a "self halt" inside KeyPressMorph>>#handleKeyboardEvent:
I clicked in the white box, and I didn't expect (maybe I just forgot about what I've read from the VM porting documentation) that each keypress would result in three events:
[97 at 692 keyDown '' (14) 1527104]
[97 at 692 keystroke 'e' (101) 1527104]
[97 at 692 keyUp '' (14) 1527221]
But more fun came when I had not clicked in the white box, and pressed Cmd-Tab to switch out of and back into Squeak:
Cmd-Tab brings one event:
[179 at 671 keyDown '<Cmd-7>' (55) 1655765]
Cmd-Tabbing back into Squeak brings another:
[179 at 671 keyUp '<Cmd- >' (0) 1671825] "note: there is a 'box' character in <Cmd-[box]>"
It all seems quite strange. I wonder if this could help pinpoint how Squeak seems to sometimes "eat" a Command key when I am switching out of it and back into it. I sometimes have to hit Cmd and/or Ctrl a few times before I can restore use of e.g. my arrow keys.
Squeak 5.2, OS X, 32-bit.
More information about the Squeak-dev