INTERATION BETWEEN CONTROLS

In previous lesson we did our first project (the clock) working only with one control and we have created a script for it. But, usually, an application has many controls interacting. Lets go to see a simple example of it.

Open a new project and drag a Button. Drag also a TextBorder.

Opening the "Object Viewer" of the Button, try to find the session: "Scripts" and drag the line:"Button emptyScript".

Open the "Object Viewer" of the Textborder and drag the line: "Text(border)'s characters <- abc" over the "Script Viewer" of the Button, like you can see at the figure (and in the video):

When you open a new Object Viewer and there are another opened, the previous will be hided and go to be represented by an icon, that can be clicked to reopen it.

Open an script for the Button (do you rememeber how to do it? no! review the "clock" exercice.). Change the script (look the figure). Our intention is: when the button is clicked, the text on the TextBorder will change.

Pay attention to the fact that was created a "prefix" for the Class TextBorder. We are using it to call the method "setCharacters:param". Here the "prefix" has the name: Textborder. But could be different ! In the video is "Textborder1" .

IMPORTANT TIP: The "prefix" of a control can change when you are doing the application. If you are having some problems in the execution of the appplication, the first verification is the names of the "prefixes". Here, drag another line "Text(border)'s characters <- abc" over the "Script Viewer" of the Button and verify - erase this line after the test, of course. Cobalt creates new version of an object if you do any change. To reopen an script, drag it from the "Object Viewer". Click in the "square" of the bar to close the script area.

Like we did for the "clock application", click: "normal", in the superior bar of the "Script Viewer". You will select how the script will run. The option here is: "mouseDown" - meaning the click on the button.

Remember to do the "accepts" etc. etc.




PREVIOUS LESSON NEXT LESSON
TABLE OF CONTENTS HOMEPAGE