links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Recipe: Creating a 'jump-to-project' button
Last updated at 8:51 pm UTC on 22 February 2017
The problem
On way to use Squeak/Morphic as a presentation system is to use each project as a slide. The slides may contain active content or just static text, pictures and sound buttons. See examples on Bob's SuperSwiki.

An important ingredient for this is a 'jump-to-project' button. Of course there is a 'jump-to-project' menu item, but for an info kiosk, for example, this is too clumsy. Two or three simple buttons like 'Previous', 'Home' and 'Next' will do the job.

Let's say we want to create a button which opens the project named 'Slide08'. This assumes that you have named each project after you have created it.

The Solution
Make sure you are in a Morphic project.

Open a Workspace and paste in the following code:

 b := SimpleButtonMorph new.
 b target: (Project named: 'Slide08').
 b actionSelector: #enter.
 b position: (World bounds bottomRight - (40  @ 40)).
 b label: 'Next'.
 b openInWorld.

Select the code and evaluate it.
(Squeak 4.1 OK)

Close the Workspace and discard the content.

The expression (Project named: 'Slide08') gives access to the Project object with the name 'Slide08'. When you send it the message 'enter' the project is opened.

All projects are kept in the class variable 'AllProject' of the class 'Project'. A Project object has an instance variable 'nextProject'. There is no setter in Squeak 3.1-4173 for this variable. Of course you can add one and make use of this and make the 'next project' button of the golden ProjectNavigation Morph functional by adding some code. But perhaps you dont want to use the ProjectNavigation Morph (Preferences 'showProjectNavigator') and implement two simple 'previous' and 'next' buttons. For this case this recipe has been written.

This works for Squeak versions 2.8 and later.

To facilitate the task you may write a utility method which takes the names of the previous, the home and the next project as arguments and creates the buttons.

Also see Project and look at the class side of Project for additional interesting information.

See also Recipe: Graphical display of all projects