[squeak-dev] How do I create a "synthetic" keyboard event?

karl ramberg karlramberg at gmail.com
Sun Feb 19 20:03:22 UTC 2023


Hi,
Try using the EventRecorderMorph.
You can record some events.
Then you can explore or inspect it to look at the instance variable tape.
It  contains all the recorded events.

EventRecorderMorph uses HandMorphForReplay to play back the recorded events.
See EventRecorderMorph>>resumePlayIn:
Once the HandMorphForReplay is set it is processed in the
WorldState>>doOneCycleNowFor:

It is quite tricky to set up this event playback.


EventRecorderMorph new openInWorld

Best,
Karl

On Sun, Feb 19, 2023 at 8:37 PM Eduardo Ochs <eduardoochs at gmail.com> wrote:

> Hi Karl,
>
> I think that now I can give a more concrete example, and ask some
> simpler questions. In one of my workspaces I have a variable "evt",
> that holds a keyboard event with a CR that I captured using the
> PolygonMorph of this e-mail,
>
>
> http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223469.html
>
> and a variable "sb", that holds the morph of the search bar - a
> PluggableTextMorphPlus. I discovered that I can simulate the action of
> typing a CR on the search bar by running this,
>
>   sb textMorph acceptContents.
>
> but it took some time to discover that "textMorph acceptContents" was
> the right message.
>
> So: 1) how do I send my evt to the morph sb? 2) How do I modify my evt
> to create an event that sends an 'a' instead of a CR?
>
> I _think_ that once I learn the answers to (1) and (2) I'll be able to
> perform certain tricks with the debugger and to use them to discover
> what are the "actions associated to certain keys" very quickly. Do you
> know how to do (1) and (2)?
>
>   Cheers, more soon,
>     Eduardo
>
>
> On Sun, 19 Feb 2023 at 14:46, karl ramberg <karlramberg at gmail.com> wrote:
>
>> To see events you can do it:
>> HandMorph showEvents: true
>>
>> I'm not sure what you want to achieve seeing the events though...
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230219/80141945/attachment.html>


More information about the Squeak-dev mailing list