[Squeakland] 2 questions - embedding text box and keystroke
listener
Ned Konz
ned at squeakland.org
Tue Dec 14 21:37:05 UTC 2004
On Saturday 11 December 2004 5:45 pm, Milan Zimmermann wrote:
> I don;t think there is a "default" eToy way to ask a Morph to respond to
> keystrokes - someone on this list (I forgot who it was, appologize for it)
> sent me the attached. If you install it, you will see in the "viewer" under
> "tests" "MyObjects 's key hit a". You can put it in a scropt, but you have
> to textually edit it to allow control by keys. Som,ething like:
>
> turnWithArrows
> (self wasCharacterHit: Character arrowUp)
> ifTrue: [self setHeading: 0.0].
> (self wasCharacterHit: Character arrowRight)
> ifTrue: [self setHeading: 90.0].
> (self wasCharacterHit: Character arrowDown)
> ifTrue: [self setHeading: 180.0].
> (self wasCharacterHit: Character arrowLeft)
> ifTrue: [self setHeading: 270.0].
>
> Hope this is what you were asking for - let me know if you need help with
> this,
My Etoy keystroke support has been added to the 3.8 update stream (from my
Squeakland work).
However, it's broken right now. I just posted a separate [FIX] for the
keyStroke event in the World (which is missing right now); you'll need it as
well.
There are two parts to this support:
* The World has a String-valued property called 'lastKeystroke'. This is a
string that holds the keystroke, in a form that can be used in string
comparisons, like:
'a'
'<left>'
'<Ctrl-left>'
This works OK now; you can have a ticking script (for instance) testing the
lastKeystroke property. But you may very well miss one, unless you use the
other part:
* You can trigger a script that is owned by the World on a 'keyStroke' event.
You do this by clicking on the 'when this script should run' button, and
choosing 'more' and then 'keyStroke'. This is the part that is currently
broken.
Anyway, with these two features you can do something like the script pictured
in the attached image, which moves a Rectangle around by keyboard command.
--
Ned Konz
http://bike-nomad.com/squeak/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MoveRectangleByKeystrokes.png
Type: image/png
Size: 17973 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041214/ad4d9b4c/MoveRectangleByKeystrokes.png
More information about the Squeak-dev
mailing list
|