Island Creator/Squeak Object: Text
From Croquet Consortium
The Squeak Object Text can be dragged from the "Green Window" to any position in the page of a project.
You can change the default word Text (or let it empty) only typing over.
Clicking in the little button "Menu" of its "halo", you have many other options for its customization. We will talk about some one.
Clicking text color (not "change color") you will see a new window.
To change the color only click that you like more.
You can change the font. But only can change the syze (here) if using the default font (BitstreamVeraSans). The recomendations is the use of the method setScaleFactor, like we will show at an example.
The letters can be bolded, underlined etc.
The text is inside a box. You can change the margins (3 options) clicking over "Margins".
Auto-Fit enables the following feature: if the text contents changes, then the bounds will be adjusted to fit the minimum rectangle that encloses the text.
Wrapping, the text will be wrapped at word boundaries based on the composition width (text margins).
Returning to the Menu options: to change the color of the background, choose change color.
The Class Text has some methods that can be used inside an script:
setCharacters:'param'.
getCharacters.
setNumericValue:n.
getNumericValue.
setScaleFactor: n
This method is the best option to change the size of the letters.
show
hide
We will do an exercice using Text for the creation of a digital clock to be inside a Cobalt island.
The idea is also to show that an script of an Squeak Object is like any other script. We can use any Smalltalk and Cobalt Classes.
Open an script for a Text. The lines of code of the script will be:
script1 |arrDT t | arrDT:= Date dateAndTimeNow. t:=arrDT at:2. self setCharacters:t. self setScaleFactor: 4.0
Click in the "normal" button of the superior Bar of the Script Viewer and choose: "ticking". The script will run in loop, showing an actualized time at each second.
Accept, save, etc. etc. and we have the clock inside the Minimum Island. Unfortunately you can't see, but the time changes at every second...
TIP: You can change the size of the Panel in the "initialize" method. But you need to place the Squeak Object in the correct position in the page or it will not appear. Look the lines of code (part of the "initialize") for our exercice:
... project3 := self makeMorphic: (MessageSend receiver: MorphicWorldHost selector: #makeProjectLink:extent:from: argument: 'proj3') extent: 700@400. win := TWindow new. win translationX: 15 y: -2 z: -15. win contents: project3. win closeContents. space addChild: win. ...
Table of Content <...> Cobalt Wiki Main Page
