[squeak-dev] How do I create a "synthetic" keyboard event?
karl ramberg
karlramberg at gmail.com
Sun Feb 19 14:57:18 UTC 2023
On Sun, 19 Feb 2023 at 15:18, Eduardo Ochs <eduardoochs at gmail.com> wrote:
> Hi Karl,
>
> ouch, so my plan is completely wrong... it was roughly this: 1) learn
> how to create synthetic keyboard events, 2) learn how to send these
> events to morphs with the debugger turned on, 3) use that to find the
> actions associated to typing certain keys in certain places, 4) become
> less of a beginner...
>
> I installed your two .mczs and tried this,
>
> EventRecordingSpace open
>
> and I got this error after just a few keys and mouse clicks:
>
> MouseButtonEvent(Object)>>doesNotUnderstand: #eventType
>
Hm.
#eventType must be charged to #type
I thought I had found all occurrences in the fix I made
I’ll answer the other questions when I get home
Best,
Karl
>
>
> I also took a look at the snapshot/source.st in the .mcz with Emacs
> (!!!). I search for "keyboardevent" there case-insensitively, and
> found very few occurrences - and none of them very enlightening...
> "keystroke" has lots of occurences, but same.
>
> Can I ask you for some suggestions and hints?
>
> a) How do you do my (3) above, i.e., "use that to find the actions
> associated to typing certain keys in certain places"?
>
> b) I've tried to learn Etoys, but many links are broken, many
> packages too, the mailing lists and forums look dead, and the
> tutorials that I could access feel very incomplete to me... for
> example, the link [1] below only has the videos 1, 10, 20, and
> 30, [2] has lots of steps that took me many hours to decypher,
> and [3] shows ways to script and connect etoys that I don't have
> any idea how to do myself... when you convince people to learn
> Etoys what are the resources - including forums and mailing lists
> - that you recommend?
>
> Thanks in advance...
> Eduardo Ochs
> http://anggtwu.net/eev-squeak.html
>
> [1] http://www.squeakland.org/tutorials/screencasts/
> [2]
> http://www.squeakland.org/content/articles/attach/The_Etoys_Quick_Guides.pdf
> [3] https://wiki.squeak.org/squeak/3913 Game programming with Etoys
>
>
> On Sun, 19 Feb 2023 at 06:18, karl ramberg <karlramberg at gmail.com> wrote:
>
>> Hi,
>> General events are a little tricky to set up and generate like you
>> describe.
>>
>> But there are tools to help you.
>>
>> You can load these two fixes and use EventRecordingSpace.
>> http://source.squeak.org/inbox/EToys-kfr.493.mcz
>> http://source.squeak.org/inbox/EToys-kfr.494.mcz
>>
>> EventRecordingSpace open
>>
>> You can record all events inside for later playback and editing saving
>> etc.
>>
>> Best,
>> Karl
>>
>> On Sun, Feb 19, 2023 at 4:43 AM Eduardo Ochs <eduardoochs at gmail.com>
>> wrote:
>>
>>> Hi list,
>>>
>>> this is a follow-up to these two messages:
>>>
>>>
>>> http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223407.html
>>>
>>> http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223408.html
>>>
>>> The first one was a question that I asked, and the second was an
>>> answer by Marcel Taeumel. I was able to decypher almost all his
>>> pointers - but not yet this one:
>>>
>>> HandMorph >> #generateKeyboardEvent:
>>>
>>> I am using this code:
>>>
>>> a := Array with: 50 at 100 with: 200 at 300 with: 100 at 400.
>>> b := (PolygonMorph
>>> vertices: a color: Color red
>>> borderWidth: 1 borderColor: Color black).
>>> World addMorph: b.
>>>
>>> b beSmoothCurve.
>>> b beStraightSegments.
>>>
>>> b vertices.
>>> b vertices at: 1.
>>> b vertices at: 1 put: 40 at 100.
>>> b vertices at: 1 put: 50 at 100.
>>> b vertices at: 1 put: 40 at 100. b computeBounds.
>>> b vertices at: 1 put: 50 at 100. b computeBounds.
>>>
>>> b color.
>>> b color: Color banana.
>>> b color: Color red.
>>>
>>> e := EventHandler new.
>>> b eventHandler.
>>> b eventHandler: nil.
>>> b eventHandler: e.
>>>
>>> bl := [ :a :b | { a . b }].
>>> bl := [ :a :b | Transcript show: { a . b }; cr. ].
>>> bl numArgs.
>>> bl value: 2 value: 3.
>>> bl perform: #value:value: with: 2 with: 3.
>>>
>>> bl := [ :evt :sm | Transcript show: { evt . sm }; cr. ].
>>> bl := [ :evt :sm | Transcript show: { evt keyValue . sm }; cr. ].
>>> bl := [ :evt :sm | self halt. ].
>>> e on: #keyStroke send: #value:value: to: bl.
>>> b currentHand newKeyboardFocus: b.
>>>
>>> It is meant to be used in a workspace. By selecting the right parts of
>>> it and running them with "do it"s or "print it"s in the right order I
>>> can create a PolygonMorph, some EventHandlers, and some blocks, and
>>> then I can make the PolygonMorph react to keyboard events in different
>>> ways. The last line switches the keyboardFocus to my PolygonMorph, and
>>> then I can send several keystroke events to my PolygonMorph, and
>>> inspect their events either on the transcript or on the debugger.
>>>
>>> Question: suppose that evt is an event whose printed representation is
>>> this one:
>>>
>>> [79 at 273 keystroke ' ' (32) 956759]
>>>
>>> I know that this means that:
>>>
>>> evt position -> 79 at 273
>>> evt type -> #keystroke
>>> evt keyValue -> 32
>>> evt keyCode -> 32
>>> evt source -> self currentHand
>>> evt timeStamp -> 956759
>>>
>>> How do I write code that creates an event like that? I would like to
>>> create, ahem, "synthetic keystrokes", and experiment with sending them
>>> to certain morphs...
>>>
>>> Thanks in advance!
>>> Eduardo Ochs
>>> http://anggtwu.net/eev-squeak.html
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230219/dfaf9f16/attachment-0001.html>
More information about the Squeak-dev
mailing list
|