Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
FAQ: How do I access a Morph from a Workspace?
Last updated at 8:17 pm UTC on 14 December 2017
From the mailing list:

Question:
Once you drag a widget out and place it somewhere, is there a way to assign it to a variable so that you can then send it messages? I realize you can create things with openInWorld, and that you can do a lot of things via halos and menus, but I also want to be able to send messages via a line of code to things already dragged out.

Answer:
You can do this easily in a workspace.

From its window menu, check "create textual references for dropped morphs". Then drop a Morph on the Workspace. It will slide back to where it was, leaving its name (bound to the Morph in the Workspace's private dictionary).

Note: Squeak 5.1 gives an error when doing this but see this post for a fix: http://forum.world.st/Error-creating-textual-references-to-dropped-morphs-td4914257.html

From there you can write code in the Workspace to use it. Keep in mind the textual reference only works in the workspace where the Morph was dropped. So, for example, if your Morph produced the textual reference 'roundRect1399793' you can simply type something like:
roundRect1399793 flashBounds
in the workspace to reference it (and make it flash visibly on the screen).

There is also the clipboard; you can copy a Morph to the clipboard and refer to it as
    ActiveHand pasteBuffer
Or you can do something like (if you know there's only one of your kind of Morph about):
    MyMorphClass allInstances first
or
    MyMorphClass someInstance

Another option is to open an inspector on the morph by the debug menu and work in the evaluation pane of the inspector.

If a Morph is created by Smalltalk code, then you might give it a name with #name: . See a morph has a name.

How do I find a morph by name?