<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi Eduardo --<div><br></div><div>Looks good so far. :-)</div><div><br></div><div>User-input events are generated from data arriving from the VM:</div><div><br></div><div>HandMorph >> #processEvents</div><div>HandMorph >> #generateKeyboardEvent:</div><div><br></div><div>Such an event is either sent to the current focus holder or just dispatched normally starting in the world:</div><div><br></div><div>HandMorph >> #handleEvent:</div><div>HandMorph >> #sendKeyboardEvent:</div><div>HandMorph >> #sendMouseEvent:</div><div><br></div><div>You can change the current focus holder via:</div><div><br></div><div>anEvent hand newKeyboardFocus: anObject.</div><div><span style="font-size: 10pt">- or -</span><br></div><div><span style="font-size: 10pt">self currentHand newKeyboardFocus: anObject.</span><br></div><div><span style="font-size: 10pt">- or -</span><br></div><div><span style="font-size: 10pt">self currentEvent hand newKeyboardFocus: anObject.</span><br></div><div><br></div><div>Note that #on:send:to: (in EventHandler) allows you to access the actual event object if you have a callback with at least 1 argument. Also note that you can just send #on:send:to: to any morph. It will install an #eventHandler if not present.</div><div><br></div><div>The overall event dispatching is encoded here:</div><div><br></div><div>Morph >> #processEvent:using:</div><div>MorphicEventDispatcher >> #dispatchEvent:with:</div><div><br></div><div>In general, there is first a "capturing phase" that does down the scene tree and the hand's position (i.e., mouse coordinates) and then a "bubbling phase" that goes up the target's (i.e., morph's) owner. Any focus holder will just change the starting point of such event dispatching ... more or less :-)</div><div><br></div><div>There is more info on that on the squeak-dev mailing list. Just click "Tools > Squeak Inbox Talk" and search the mails from about the last 3-4 years.</div><div><br></div><div>Hope this helps. Happy squeaking!! :-)</div><div><br></div><div>Best,</div><div>Marcel</div><div><br></div><div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 09.02.2023 07:32:48 schrieb Eduardo Ochs <eduardoochs@gmail.com>:</p><div style="font-family:Arial,Helvetica,sans-serif">Hi list,<br><br>I asked this question here on the list a few days ago,<br><br>http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223398.html<br><br>on how to write code that _sends_ certain keyboard events. I think<br>that I got a prototype of an answer for it, that "just" needs some<br>debugging... and then I started to work on ways to debug my prototype.<br><br>The ideal way to test sending keyboard events would be to have some<br>code that _receives_ and _handles_ keyboard events, and that runs<br>things like "Transcript show: evt" or "evt halt" when it receives a<br>keyboard event. I tried to adapt the code from these wiki pages<br><br>  https://wiki.squeak.org/squeak/1125 Programming Morphs (Active Essay)<br>  https://wiki.squeak.org/squeak/1216 Programming morphs - page 7 -<br>keyboard events<br>  https://wiki.squeak.org/squeak/3503 Morphic Key Events<br><br>without much success, and I also tried to modify the keyboard<br>exerciser - i.e., this:<br><br>  "World menu -> objects (o) -> Categories -> Demo -> Exercise Keyboard"<br>  KeyboardExerciser new openInWorld.<br><br>...and then I saw a way to play with keyboard handlers that does not<br>require creating any classes or modifying any methods, and that can be<br>run entirely from a workspace with "do it"s and "print it" in the<br>right places. It is here:<br><br>  "The first lines were adapted from:<br>    https://wiki.squeak.org/squeak/2188 PolygonMorph"<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>  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>  a at: 1 put: 40@100. b computeBounds.<br>  a at: 1 put: 50@100. b computeBounds.<br><br>  b color.<br>  b color: Color banana.<br>  b color: Color fern.<br>  b color: Color red.<br><br>  e := EventHandler new.<br>  b eventHandler.<br>  b eventHandler: nil.<br>  b eventHandler: e.<br><br>Now how do I change that event handler in interesting ways?<br>Does this make sense?<br><br>  e on: #keyStroke send: #halt to: b.<br><br>Also, is there a way to transfer the keyboard focus to the<br>PolygonMorph with a "do it" in that workspace? I guess that we<br>need to run the method #newKeyboardFocus:, but how exactly?<br>Anyone has examples to share?<br><br>  Thanks in advance,<br>    Eduardo Ochs<br>    http://anggtwu.net/eev-squeak.html<br><br></div></blockquote>
                                        </div></div>