PAGE NAVIGATION

Programming using a graphic interface can be dificult for old programers. But, after to learn, the productivity will be very hight.

We will mix graphic programming and the use of statements. The "golden rule" will be:

IF POSSIBLE, USE GRAPHIC PROGRAMMING.

Lets go to learn by example:

We need to create a program to do: " when the user clicks the image with the word Books, in any page, he will go to the pageAAAA".

This program will be a function of the object that is the image/sketch. We will change its name to be : Books.

Opening its Viewer click in the button(?) at left of the name.

Will open a menu where we select: add new script. Will appear a kind of stamp that we will drag to an empty place. Droping it, will appear the "Script Editor" for the script1 of Books.

It's possible to move the Script Editor to any place.

The object SiteBS (the correct would be to say: the Class BookMorph) has a function goto: where the parameter is the page to go.

So, we will need to use, inside the script glued to Books, two objects: SiteBS and PageAAAA.

First we need to open the Viewer of SiteBS. Drag the line "SiteBS's x" by the arrow (look the figure) until it is over the ScriptEditor. You will see a green square when it's time to drop it.

Now drag the Script Editor out of the area of the Book, go to the next page and open the Viewer for PageAAAA. Do the same thing (look the figure):

FOR OOP PROGRAMERS: What kind of magic are we doing? We are creating graphically, inside the object Books, instances of SiteBS and PageAAAA to be used.

Now we have the 2 objects inside the script but the code is not what we need. We open the script clicking in the square (3th from left):

We need to rewrite the code . It will be:

SiteBS goto: PageAAAA5.  

WARNING: DON'T FORGET TO DO THE accept! It's the most commom error in Squeak programming.

OBSERVATION: Look to the figure. The object of PageAAAA is, for us, PageAAAA5. This depends of how many "Saves" you did. This automatic changement can create problems at the final version of the application. If something doesn't work, can be because of the modification of version of some objects.You will need to make the corrections in the codes.

Now we have this new function of the object Books. How to run it when the user clicks the image?

Click, in the ScriptEditor, the button having the title: "Normal" and will open a list where you select: "Mouse down".

TIP: Here you are learning how to create a script for any graphic object, that can be triggered by many types of events like MouseEnter, MouseLeave etc.!

Go back to the Homepage and click the object Books. If you didn't forget to do the "accept" all will work OK.

An interesting thing about Squeak is: if you Duplicate the object (using the green button of the Halo) it will have all the inteligence defined for it. So, lets go to create 3 duplications of the object Books and put them in the other pages.

TIP: Remember that you need to define the "embed into" for each one.

We need to do similar scripts and duplications for the other objects (Welcome, Video and Viewcart). This is a good "homework" for you...

TIP: If the object doesn't like to be in front of the logo, in the Menu you can define: "bring to front".

In the next lesson we will create the logic for when some user buys some books.


PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE

DISCLAIMER: This material can be translated for any language, and reproduced total or partially by anybody using any type of media. But, please, don't put your name like author. And let me know if it was useful (americo@dmu.com).The use of any code, 3D model or technique published is free and doesn't need to have any reference about this source.The author is not responsible for any damage that the material can cause to your professional or sexual life.