[Q] E-Toy: How to hook a button to other object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Q] E-Toy: How to hook a button to other object

Young-Jin Lee-3
Hi,

I am a newbie and trying to learn how to develop educational material
using E-Toy.
I went through several E-toy project, but still need some helps.

In the test program I was writing, I put a few text objects and a
Button object from "Supplies" tab. My object was to change the text of
one of the text objects when the Button is clicked.

First, I opened a Viewer for the Button object to figure out what
kinds of things I can do to this Button object. I expected to find a
method that will be invoked when the button object is clicked. To my
surprise, there is no such method.

I was able to achieve the goal by (1) creating a script to change the
text of one of the text objects and (2) creating "Button to fire to
this script". But, I don't think this method is in sprite of Squeack,
visual programming. I want to first create a button and make this
button change the text of one of the text objects when this button is
clicked, not the other way around. To me, this approach is in line of
Squeak's philosophy.

Can any one please explain what I have missed?

Thanks in advance.

Young-Jin
_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: [Q] E-Toy: How to hook a button to other object

Yoshiki Ohshima
  Hello, Young-Jin,

> I was able to achieve the goal by (1) creating a script to change the
> text of one of the text objects and (2) creating "Button to fire to
> this script". But, I don't think this method is in sprite of Squeack,
> visual programming. I want to first create a button and make this
> button change the text of one of the text objects when this button is
> clicked, not the other way around. To me, this approach is in line of
> Squeak's philosophy.
>
> Can any one please explain what I have missed?

  There are a quite a few different ways.

  #1:
   * For the "Button" from the supplies bin, get the halo for it.
   * There is a pale green/blue handle near the bottom right corner.
   * You'll get the scriptor that is invoked when you click it.  (You
     can programatically invoke the button's action by sending "fire"
     command in the "button" viewer category.

  #2:
   * For any object, you can make it a button.
   * Create a scriptor for an Etoys object.
   * Hold the mouse button for a second on the "script status" that is
     showing "Normal" by default.  You'll get a menu.
   * From the menu, choose "mouseDown" or "mouseUp".  The script will
     be executed when you do click on (or click on and release) the
     object.

-- Yoshiki
_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: [Q] E-Toy: How to hook a button to other object

Alan Kay
In reply to this post by Young-Jin Lee-3
Hi --

Actually, any script can produce a button to fire it, and also, any object in Etoys can serve as a button (including text objects).

1. Suppose you have a text object named Text that contains some text: 'This is some text'.

Drag out Text's characters <- This is some text onto the desktop to make a script.

Do it again to make a second script. Name the first script "reset" and the second one "change".

Change the text in the "change" script.

These scripts can be tested by clicking on the (!).
A script will give you a button to fire it. Look at the menu item in a script    []

and choose the item button to fire this script.

Do this for the other script. Both of these buttons can be relabeled.

Here is what this example looks like
[]

2. You can also use any object as a button. Get out a rectangle. Put an empty rectangle script on the desktop. Put the tiles:
Text's characters <- This is different text in this script. Now look at the normal menu and choose mouseUp. This script will fire when you do mouseUp on the rectangle object.

[]

You can make a toggle by adding a variable to hold true or false, etc.

Cheers,

Alan

At 05:18 PM 3/3/2007, Young-Jin Lee wrote:








Hi,

I am a newbie and trying to learn how to develop educational material
using E-Toy.
I went through several E-toy project, but still need some helps.

In the test program I was writing, I put a few text objects and a
Button object from "Supplies" tab. My object was to change the text of
one of the text objects when the Button is clicked.

First, I opened a Viewer for the Button object to figure out what
kinds of things I can do to this Button object. I expected to find a
method that will be invoked when the button object is clicked. To my
surprise, there is no such method.

I was able to achieve the goal by (1) creating a script to change the
text of one of the text objects and (2) creating "Button to fire to
this script". But, I don't think this method is in sprite of Squeack,
visual programming. I want to first create a button and make this
button change the text of one of the text objects when this button is
clicked, not the other way around. To me, this approach is in line of
Squeak's philosophy.

Can any one please explain what I have missed?

Thanks in advance.

Young-Jin
_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland