Fun with KeyPressMorph

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fun with KeyPressMorph

Tim Johnson-2
Hi,

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@692 keyDown '' (14) 1527104]
[97@692 keystroke 'e' (101) 1527104]
[97@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@671 keyDown '<Cmd-7>' (55) 1655765]

Cmd-Tabbing back into Squeak brings another:

[179@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.

Best,
Tim J


Reply | Threaded
Open this post in threaded view
|

Re: Fun with KeyPressMorph

K K Subbu
I found some anomalies too, Squeak 5.2-18225 Linux-64b.

When I click inside the KeyPressMorph and press 'f' key, the letter 'f'
is displayed but the key is not consumed by this morph. It is also
passed to the previous Browser window that I was using.

A KEY_DOWN of any modifier key immediately results in a keycode:

  ALT -> <cmd-opt-+>
  SHIFT -> <opt-ÿ>
  CTRL -> <ctrl-opt-û>

instead of waiting till KEY_UP to compute the complete key code.

I also found the "Press new key" bubble to jiggle up and down by about
one pixel and reproduced it in an inspector:

    self say: 'jiggle'

If I inspect "self bubble bounds origin" at this stage, its y keeps
changing by 1 (e.g. 541 and 542). However, if I print y (self bubble ...
origin y), the value is steady at the lower one (541). Somehow, the act
of accessing y kills the cat ;-).

HTH .. Subbu

On 08/11/18 12:09 PM, Tim Johnson wrote:

> Hi,
>
> 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:
> 8225
> [97@692 keyDown '' (14) 1527104]
> [97@692 keystroke 'e' (101) 1527104]
> [97@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@671 keyDown '<Cmd-7>' (55) 1655765]
>
> Cmd-Tabbing back into Squeak brings another:
>
> [179@671 keyUp '<Cmd-
> 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.
>
> Best,
> Tim J
>
>