smalltalkpharosqueakmorphic

Squeak - How do I move a circle?


In the Squeak Smalltalk environment, I am trying to learn Morphic. There are many, many Morphic classes and I cannot determine the most appropriate one(s) to use for my current application, and I prefer not to invent anything that already exists at this point. Links to relevant code/info would be appreciated. While Pharo might be nicer, I am stuck with Squeak atm.

My question is:
Using Squeak and Morphic, how do I create some sort of canvas, drop it into a movable, scrollable, resizable window, show it on the desktop, drop a circleMorph onto that canvas, and allow the user to grab the circle and move it around on the canvas?

Thanks!


Solution

  • Open a workspace and type:

    | window canvas circle |
    window := SystemWindow new.
    canvas := PasteUpMorph new.
    window addMorphBack: canvas.
    canvas bounds: window bounds.
    circle := CircleMorph new.
    canvas addMorphCentered: circle.
    window openAsIs.
    

    This will create a circle on your desktop that you can drag and drop. Browse the CircleMorph class to find other things you can do. Also, check out the Documentation section at www.squeak.org. There's a lot of good tutorials there.