Hello Jeff :-)<br><br>interesting question, and I know the situation you're describing with respect to getting the help you want.<br><br>OK, to the point of your problem: you want to turn a Wonderland actor (your helicopter) in response to a mouse click. Here is a quick, concrete recipe, tested in Squeak
3.8:<br><br>1) As you did, evaluate ("do it" ) this:<br><br>| wonder copter |<br><br>wonder := Wonderland new.<br>copter := wonder makeActorFrom: 'WonderlandObjects\Vehicles\Helicopter.mdl'.<br><br>2) Now _within_ the wonderland script window, evaluate this:
<br><br>helicopter addResponse: [:event | helicopter turn: #left] to: #leftMouseUp<br><br>3) click on your helicopter and see what happens<br><br>Does that do what you want?<br><br>------------<br><br>Now, how did I find out about this? (I'm not saying you should be able to find this out for yourself, mind you. I'm just trying to help.)
<br><br>1) Notice the Quick reference tab in the wonderland window<br><br>2) Somewhere down in that text you find<br><br><br>Adding Reactions<br>--------------------<br><br>Useful constants:<br> event types: keyPress, leftMouseDown, leftMouseUp, leftMouseClick,
<br> rightMouseDown, rightMouseUp, rightMouseClick<br><br>addResponse: <block> to: <eventType><br>removeResponse: <response> to: <eventType><br>respondWith: <block> to: <eventType>
<br><br><br>3) So it has to be something with addResponse. I still don't know how to use the addResponse, however. So I open the method finder and type in addResponse<br><br>4) I find the method addResponse:to: in WonderlandActor
<br><br>5) looking at the method source code in the browser, I don't get a idea of how to use it. In most cases it's better to look at examples of the method in use, so I click on "senders"<br><br>6) bummer: there are no senders of addResponse:to: !
<br><br>7) in that same method category "event handling" there is another method that looks similar: respondWith:to:, and that's also listed in the wonderland quick reference<br><br>8) I find 3 senders of respondWith:to:, among them
<br><br><br>initializeDefaultReactions<br> "Set up our default reactions"<br> myReactions := Dictionary new.<br> self respondWith: [:event | self onLeftMouseDown: event] to: leftMouseDown.<br> self respondWith: [:event | self onLeftMouseUp: event] to: leftMouseUp.
<br><br>9) So I interpret the method as this: There is a dictionary myReactions that tells the actor what to do in response to an event. Event types are the keys, blocks are the value of this dictionary. They initialize the reactions to left mouse down and left mouse up with blocks that specify what to do on these events. Now it makes sense: the block takes the event as an argument, so you can ask the event object
e.g. for the mouse coordinates<br><br>10) Now I have the basic format for the block, and an example on how to use it<br><br>11) The last obstacle was to be able to "name" the helicopter inside the wonderland, because it takes on its own name ("helicopter" instead of the "copter" you used in the script).
<br><br>I fully realize that this discovery process needs a lot of assumptions and background knowledge about Squeak. I think this knowledge can be gradually accumulated by playing with the system and trying to get small things done. When you're stuck, you can always ask the mailing list.
<br><br>--------<br><br>I hope this helps, have fun.<br><br>Matthias<br><br><br><div><span class="gmail_quote">On 11/7/06, <b class="gmail_sendername">Jeff</b> <<a href="mailto:firstname.lastname@example.org">email@example.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello group!<br><br>I'm hoping that this beginners list is a good place for a beginner to get answers to... well, beginner's questions. And so, with that in mind, I'll ask a few questions. But first, experience has taught me that I should be a little more clear in what I'm looking for as an answer. [...]
<br>1. In a workspace, I've typed the following...<br><br>wonder := Wonderland new.<br>copter :=
wonder makeActorFrom: 'Objects\Vehicles\Helicopter.mdl'.<br>copter turn:'left'.<br><br>So far, everything works fine. The wonderland and helicopter are created, and I am able to send it messages to make it turn, move, etc. Now I'd like to make it move by using the arrow keys. How do I do that? [...]