Ned,
That is cool, BTW did you write the cs I attached to my last message (and that has been eaten by the list I just found, so re-attaching it). Someone on the list sent it to me, I forgot who, and was lazy to search. Yours is probably more integrated in the viewer (I mean the <down> etc), in the attached that I use I do not know how to do script non-textual. Thanks Milan
On December 14, 2004 04:37 pm, Ned Konz wrote:
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.