View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

PluggableButtonMorph

The comments are decent for this class in Squeak. It took a little while to get used to the terminology of selector. A selector is almost always a method call in the form of a symbol. The selector basically selects what method to call based on the instance's model.

Useful Code

A semicolon says to send the following message to the same object as the previous method's receiver. Consequently, you only have to type myButton once, since all of the methods are part of and sent to myButton. The code below gives a label to the button, makes it visible, sets the model of the button to the class that contains the button, makes it so that when the button is pressed, the dropItemMenu method is called (this method is contained within the class that has myButton), says to give the dropItemMenu method the arguments returned by aMethod, aMethod is found inside of a variable of the parent morph. It also ensures the morph is unlocked and sets the color of the morph. As a word of caution argumentsSelector: often expects a collection of some sort so that aMethod may have to return a collection.

myButton = PluggableButtonMorph new.
myButton label: 'Drop Item'; visible: true;
model: self; action: #dropItemMenu:;
argumentsProvider: (owner getMethod model)
argumentsSelector: #aMethod;
lock: false;
color: (Color lightGreen).

Useful Methods

Sets the label.
label: aStr

Sets the model
model: anObject

Link to this Page