Defining the public interface
Use the Public Interface Editor to define the shape part's public interface. For now, define one attribute, shape, which determines the appearance of the shape part. Use the following settings in the Public Interface Editor's Attribute page:
Get selector
shape
Set selector
shape:
Change event symbol
shapeChanged
Attribute data type
String
Then select Add. When you create parts that directly or indirectly inherit from AbtBasicView (like this one), do not use the Add with defaults push button. This is because classes inheriting from AbtBasicView assume special optimizations if a method has the same name as a change event symbol. Adding the word Changed as a suffix on the change event symbol is an easy way to avoid any problems.
Generate the default script and the instance variable for the attribute, and then modify the get and set methods so that they look like the following code:
shape: aString
"Set the shape attribute"
shape := aString.
self signalEvent: #shapeChanged with: shape.
self draw.
shape
"Answer the shape attribute"
shape isNil ifTrue: self shape: 'circle'].
^shape.
Notice that the default appearance is a circle. Also notice that the set selector redraws the shape after the attribute value has been changed. Now you need to make the shape objects understand the draw message. Write that method next.
Last modified date: 01/29/2015