Defining the attributes
On the Attribute page, you define the names of the attributes that appear on the part's pop-up menu. Usually, the attribute name matches an instance variable name. You can make the attribute name different from the instance variable name if you want to, but it is usually best to make the names match. You can also have attributes that are derived attributes, which means that they are determined from other values, not stored as an instance variable. Let's add the length attribute: In the Attribute name field type length, and select Add with defaults.
Your Public Interface Editor looks like the following:
Notice the default values that are displayed:
•The default Get selector is length, which means that whenever the timer part is asked for its length value, the length method is run. Later, you'll write this method, which returns the length instance variable's value. You can also choose to generate the length script automatically.
•The default Set selector is length:. When a connection causes the length attribute to change, the length: method runs, storing the new value.
•The default Change event symbol is length. Whenever the set selector is run, the part must signal this event to let other parts know that the value has changed.
•The default Attribute data type is Object. Because length is an integer value, change this value to Integer, and select Update.
To understand how these selectors are used, imagine how your timer part might be used in a VA Smalltalk window. Suppose the window has one text-entry field with an attribute-to-attribute connection between your timer part's length attribute and the text-entry field's object attribute. The get selector runs when the window first opens, to get your timer's length attribute and set its value into the text-entry field. If the user types a different value into the text-entry field, the set selector updates the timer's length attribute.
Adding the repeat attribute
Add the repeat attribute by typing repeat in the Attribute name field and selecting Defaults. Change the value in the Attribute data type field to Boolean, and select Add.
Last modified date: 06/11/2018