[[TOC]] = Squeak FAQ - New Version = == Documentation == === Where do I find good introductory literature for !Squeak/Smalltalk? === The book [http://www.squeakbyexample.org/ Squeak by Example] is a good starting point. Especially, the book explains the most important tools, the morphic framework and important concepts, such as messages. In the [http://wiki.squeak.org/squeak/792#Morphic morphic wiki] you can find tutorials how to work with morphic and squeak. There are also many books available for free: An overview can be found here: [http://stephane.ducasse.free.fr/FreeBooks.html Stephane Ducasse: Free Books] We also created some [https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/squeak_screencasts screencasts] explaining how to work with squeak. === Where do I find a good documentation? === For most of the classes you can view the documentation directly in the browser. The "?" Button between class and instance shows class comments. Furthermore, we recommend the following websites: * [http://squeakbyexample.org/ Squeak by Example] * [http://static.squeak.org/tutorials/morphic-tutorial-1.html Morphic Tutorial] * [http://wiki.squeak.org/squeak/30 Squeak-Wiki] * [https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/squeak_screencasts Squeak Screencasts] * [http://wiki.squeak.org/squeak/5699 Terse guide to Squeak] == Smalltalk Syntax == === How do I leave a method without returning a value, e.g. early return? === In Smalltalk `^` behaves similar to return in other languages. If a method in Smalltalk should return nothing, typically you return `self`. You should avoid to return `nil`. === How do I break inside a loop? === A way to do so is to put the loop into its own method and to add another return. However, you should consider the collection protocol. Usually, there already is a method, that solves your problem. Possible methods could be: `#detect:ifFound:ifNone:` or `#detect:thenDo:ifNone:`. === Are there abstract classes in Smalltalk and how should I name them? === In Smalltalk a class is abstract when a method is implemented with "self subclassResponsibility". However, you can still create objects of this class, but this method cannot be called. A typically idiom is to extend the name with the word "Abstract". Examples in the image are: !AbstractEvent, !AbstractFont, or !AbstractSound. == Idioms and Patterns == === How to I access class variables or methods? Via classname or self class? === == I/O == == Graphic (Morphic) == === How do I repeat an image in the background? === An image can be repeated in the Background using an !InfiniteMorph as a morph's fill-style: {{{ aForm := Form fromFileNamed: 'picture.png'. anInfiniteForm := InfiniteForm with: aForm. Morph new extent: 500@500; fillStyle: anInfiniteForm; openInHand. }}} === How do I react on deleting morphs using halos? === If a morph is deleted using the X in the halo menu, `Morph>>dismissViaHalo`, `Morph>>dismissMorph`, `Morph>>delete` are called. If your morph is a subclass of Morph, you can overwrite one of these. Do not forget to call the super implementation. === How do I prevent a Morph from stepping directly after opening? === `Morph>>wantsStep` can be overwritten returning false. As a result the morph will not start stepping immediately. Nevertheless, you can start stepping with `Morph>>startStepping` later on. === How do I implement a parallax scrolling for background images? === === How do I change the size of an image independent from the aspect ratio? === A Form can be scaled using `Form>>#magnify:by:smoothing:`. The scale factor can either by a single value or a point to define the scale factor for both height and width. The following examples shows how to change the size to 100@50 independent from the original aspect ratio: {{{ MenuIcons helpIcon in: [:form | (form magnify: form boundingBox by: (100@50) / form extent smoothing: 1) asMorph openInHand]. }}} === How do I insert morphs in the background?=== Instead of using `addMorph:` you can use the following methods to influence the z-level of morphs: `#addMorph`, `addMorphFront:`, `#addMorph:behind:`, and `#addMorph:inFrontOf:`. === How do I rotate a morph? === To rotate a morph you can create a !TransformationMorph around your morph and change the angle using: `TransformationMorph>>angle:` {{{ aForm := Form fromFileNamed: 'picture.png'. anImageMorph := aForm asMorph. aTransformMorph := TransformationMorph new asFlexOf: anImageMorph. aTransformMorph openInHand. aTransformMorph angle: Float pi/4 negated. }}} If you want to rotate a local Resource only once at the beginning, you can create a From and rotate it using `From>>rotateBy:` You can rotate it later on by creating another rotated copy and exchanging the from of the !ImageMorph. However, this is inperformant if used often. {{{ aForm := Form fromFileNamed: 'picture.png'. anImageMorph := aForm asMorph. anImageMorph image: (aForm rotateBy:45 smoothing:10). anImageMorph openInHand. anImageMorph image: (aForm rotateBy:90 smoothing:1). }}} == Sound == == Image Concept == == Squeak == === How do I change the author initials? === For future code changes you can change your author initials via menu as shown in the picture below. == Seaside == == Gemstone == == Versioning (Monticello) == == Patterns and Idioms == == Other ==