Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
PartsBin
Last updated at 4:24 am UTC on 13 October 2005
Here is some sample code for creating a parts bin:

PartsBin newPartsBinWithOrientation: #leftToRight from: (
   OrderedCollection new addAll:#(
      (RectangleMorph authoringPrototype 'My Morph' 'Opens a copy of my morph')
      (RectangleMorph authoringPrototype 'Another' 'Another morph, fun isn''t it?')))


This will create a basic parts bin with one object.

Orientations take the form #leftToRight and #topToBottom.

The from: takes a quadList in the form (receiver selector 'label' 'balloonHelp').

The word quadList is a bit misleading. It doesn't actually set up a 4-tuple, but a 3-tuple. The method authoringPrototype is implemented in Morph, so any morph can use it. I don't completely understand its behaviour, but it sets up the returned object to be in a "tear off" mode that the parts bin can use.

Each PartsBin creates a set of IconicButtons corresponding to the object you want to create. The target of the button is the object you put first in the 3-tuple. The message sent to this object for creation is #launchPartVia:label: with the arguments of the selector and the label. From the above example, the first object in parts bin would be created like this when pulled out:
RectangleMorph launchPartVia: #authoringPrototype label: 'My Morph'

This will create a RectangleMorph in hand that has the label 'My Morph' associated with it.