I have tried posting these in the forum, but it seems that no one is really looking there, so I am going to post them here:
1) i am trying to embed a text box into a painted object so that it looks and acts like one object. basically i want to be able to pick up and move the item as one, but still be able to script the textbox's behavior. i am have tried the embed action, but it only says i can embed into "world." any ideas?
2) What is the best way to "listen" for keystrokes? Example: the user hits the left arrow key and the object moves to the left.
1) Drag a playfield from the flap. Embed both the paint object and the text box into the image.
2) Smalltalk code in the Tetris game class is one example of a keystroke listener but you have to have your mouse over the morph for it to receive the keystrokes. Morphs moving around make this hard to do.
----- Original Message ----- From: "Arvind S. Grover" AGrover@hewittschool.org To: squeakland@squeakland.org Sent: Thursday, December 09, 2004 1:05 PM Subject: [Squeakland] 2 questions - embedding text box and keystroke listener
I have tried posting these in the forum, but it seems that no one is really looking there, so I am going to post them here:
- i am trying to embed a text box into a painted object so that it
looks and acts like one object. basically i want to be able to pick up and move the item as one, but still be able to script the textbox's behavior. i am have tried the embed action, but it only says i can embed into "world." any ideas?
- What is the best way to "listen" for keystrokes? Example: the user
hits the left arrow key and the object moves to the left.
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
If you put the object to be embedded on the object which you want to be the holder, then the embed popup will show you all the layers you can embed in down to the world. If you want to be completely clear about what is going where, you can do one of two things. . you can name the object that will be doing the holding by clicking on the name that shows up with the halo, typing and hitting return (and this name will then show in the embed popup), or . you can look at the red menu for the holder object and choose "open to drag and drop". Now it will act like a playfield. The object will now capture any object dropped on it (but this can be too much of a good thing, so it is often good to turn this option off after you've done your desired embedding.
Perhaps Scott or Ned can tell us about the current state of keyboard listening in the etoy system (the feature is there but turned off, again for good reasons).
Cheers,
Alan
At 03:33 PM 12/11/2004, darius@inglang.com wrote:
- Drag a playfield from the flap. Embed both the paint object and the
text box into the image.
- Smalltalk code in the Tetris game class is one example of a keystroke
listener but you have to have your mouse over the morph for it to receive the keystrokes. Morphs moving around make this hard to do.
----- Original Message ----- From: "Arvind S. Grover" AGrover@hewittschool.org To: squeakland@squeakland.org Sent: Thursday, December 09, 2004 1:05 PM Subject: [Squeakland] 2 questions - embedding text box and keystroke listener
I have tried posting these in the forum, but it seems that no one is really looking there, so I am going to post them here:
- i am trying to embed a text box into a painted object so that it
looks and acts like one object. basically i want to be able to pick up and move the item as one, but still be able to script the textbox's behavior. i am have tried the embed action, but it only says i can embed into "world." any ideas?
- What is the best way to "listen" for keystrokes? Example: the user
hits the left arrow key and the object moves to the left.
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
On Sunday 12 December 2004 7:55 am, Alan Kay wrote:
Perhaps Scott or Ned can tell us about the current state of keyboard listening in the etoy system (the feature is there but turned off, again for good reasons).
Actually, it's broken right now. I have sent Michael a fix.
There are two parts:
* 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.
The attached change set fixes this problem, if you want to experiment with it and know what to do with change sets. Otherwise, you will have to wait for the fix to appear as a Squeakland update.
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.
At 4:05 PM -0500 12/9/04, Arvind S. Grover wrote:
- i am trying to embed a text box into a painted object so that it
looks and acts like one object. basically i want to be able to pick up and move the item as one, but still be able to script the textbox's behavior. i am have tried the embed action, but it only says i can embed into "world." any ideas?
Hi, Arvind,
The trick in embedding object A into object B is to make certain that the *center* of object A is *over* some part of object B. When you do that, you will see B offered as a potential embedding target for object A when you bring up A's halo menu and choose "embed."
Once you've succeeded in embedding object A into object B, you can reposition it *within* object B by dragging it via the brown halo handle.
Hope this helps,
-- Scott
Please see inline: On December 9, 2004 04:05 pm, Arvind S. Grover wrote:
I have tried posting these in the forum, but it seems that no one is really looking there, so I am going to post them here:
- i am trying to embed a text box into a painted object so that it
looks and acts like one object. basically i want to be able to pick up and move the item as one, but still be able to script the textbox's behavior. i am have tried the embed action, but it only says i can embed into "world." any ideas?
I assume your painted object has just lines or lots of "empty" areas - the problem is that you have to position your text box "just right" over some painted area of the painted object for the "embed into PaintedObject" to appear in the text box's menu. I had the same problem but it can be done with a bit of trying...
- What is the best way to "listen" for keystrokes? Example: the user
hits the left arrow key and the object moves to the left.
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,
Milan
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
squeakland@lists.squeakfoundation.org