<div dir="ltr"><div>Hi,</div><div>General events are a little tricky to set up and generate like you describe.</div><div><br></div><div>But there are tools to help you.</div><div><br></div><div>You can load these two fixes and use EventRecordingSpace.<br></div><div>
<a href="http://source.squeak.org/inbox/EToys-kfr.493.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/EToys-kfr.493.mcz</a>

</div><div>
<a href="http://source.squeak.org/inbox/EToys-kfr.494.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/EToys-kfr.494.mcz</a></div><div><br>


</div><div>EventRecordingSpace open</div><div><br></div><div>You can record all events inside for later playback and editing saving etc. <br></div><div><br></div><div>Best,</div><div>Karl<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 19, 2023 at 4:43 AM Eduardo Ochs <<a href="mailto:eduardoochs@gmail.com" target="_blank">eduardoochs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi list,<br>
<br>
this is a follow-up to these two messages:<br>
<br>
<a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223407.html" rel="noreferrer" target="_blank">http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223407.html</a><br>
<a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223408.html" rel="noreferrer" target="_blank">http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223408.html</a><br>
<br>
The first one was a question that I asked, and the second was an<br>
answer by Marcel Taeumel. I was able to decypher almost all his<br>
pointers - but not yet this one:<br>
<br>
  HandMorph >> #generateKeyboardEvent:<br>
<br>
I am using this code:<br>
<br>
  a := Array with: 50@100 with: 200@300 with: 100@400.<br>
  b := (PolygonMorph<br>
          vertices: a color: Color red<br>
          borderWidth: 1 borderColor: Color black).<br>
  World addMorph: b.<br>
<br>
  b beSmoothCurve.<br>
  b beStraightSegments.<br>
<br>
  b vertices.<br>
  b vertices at: 1.<br>
  b vertices at: 1 put: 40@100.<br>
  b vertices at: 1 put: 50@100.<br>
  b vertices at: 1 put: 40@100. b computeBounds.<br>
  b vertices at: 1 put: 50@100. b computeBounds.<br>
<br>
  b color.<br>
  b color: Color banana.<br>
  b color: Color red.<br>
<br>
  e := EventHandler new.<br>
  b eventHandler.<br>
  b eventHandler: nil.<br>
  b eventHandler: e.<br>
<br>
  bl := [ :a :b | { a . b }].<br>
  bl := [ :a :b | Transcript show: { a . b }; cr. ].<br>
  bl numArgs.<br>
  bl value: 2 value: 3.<br>
  bl perform: #value:value: with: 2 with: 3.<br>
<br>
  bl := [ :evt :sm | Transcript show: { evt . sm }; cr. ].<br>
  bl := [ :evt :sm | Transcript show: { evt keyValue . sm }; cr. ].<br>
  bl := [ :evt :sm | self halt. ].<br>
  e on: #keyStroke send: #value:value: to: bl.<br>
  b currentHand newKeyboardFocus: b.<br>
<br>
It is meant to be used in a workspace. By selecting the right parts of<br>
it and running them with "do it"s or "print it"s in the right order I<br>
can create a PolygonMorph, some EventHandlers, and some blocks, and<br>
then I can make the PolygonMorph react to keyboard events in different<br>
ways. The last line switches the keyboardFocus to my PolygonMorph, and<br>
then I can send several keystroke events to my PolygonMorph, and<br>
inspect their events either on the transcript or on the debugger.<br>
<br>
Question: suppose that evt is an event whose printed representation is<br>
this one:<br>
<br>
  [79@273 keystroke ' ' (32) 956759]<br>
<br>
I know that this means that:<br>
<br>
  evt position -> 79@273<br>
  evt type -> #keystroke<br>
  evt keyValue -> 32<br>
  evt keyCode -> 32<br>
  evt source -> self currentHand<br>
  evt timeStamp -> 956759<br>
<br>
How do I write code that creates an event like that? I would like to<br>
create, ahem, "synthetic keystrokes", and experiment with sending them<br>
to certain morphs...<br>
<br>
  Thanks in advance!<br>
    Eduardo Ochs<br>
    <a href="http://anggtwu.net/eev-squeak.html" rel="noreferrer" target="_blank">http://anggtwu.net/eev-squeak.html</a><br>
<br>
</blockquote></div>