Adding settings pages
The most typical way to set a part's shape attribute is through the part's settings view. Because shape is a new attribute, it is not set in any of the settings pages that the part inherits. One way to add the shape attribute to the settings view is by adding another page to the settings notebook. First, create a new visual part called MyShapeSettingsView in MyEditSamplePartsApp. Make the part look like the following:
Part
Notice that the view uses a Form part instead of a Window part as its primary part. The Form part has a Drop-down List part. Open the settings of the Drop-down List part and add the circle, rectangle, and triangle choices to its list of initial items.
As you learned in Custom settings view, updateOperation is a special variable that VA Smalltalk uses to connect this settings page to a specific part. Use these steps to add and connect the updateOperation variable:
1. From the Models category select a Variable part and drop it on the free-form surface. From the variable's pop-up menu, select Change Type. Enter MyShape as the new type.
2. Change the variable's name to updateOperation. The exact spelling and case of the name is important because it has special meaning to VA Smalltalk.
3. From the variable's pop-up menu, select Promote Part Feature. When the promote window is displayed, select self from the Attribute list. Be certain updateOperation is displayed in the Promote feature name field.
4. Select Promote, then press OK to close the window.
5. Connect the Drop-down List part's selectedItem attribute to the updateOperation part's shape attribute.
Because this part will be an entry in the settings notebook, save the part and add the following class method to MyShape:
settingsPageNames
"Add a new entry to the properties table."
^(super settingsPageNames
addFirst: MyShapeSettingsView;
yourself)
Move this method to your edit application, MyEditSamplePartsApp. This method will add the settings that are specific to your part to the first page of the General section of the settings notebook. This is the same approach that is used by VA Smalltalk parts.
Occasionally, you will want to add your own pages as a separate section of the settings notebook. To do this, open the Script Editor on your settings part (MyShapeSettingsView) and add the following two class methods to the part. These methods define the text and style of the notebook tab for this page.
tabDisplayName
"Answer the name of the settings page's tab"
^'Shape'
tabType
"Make the settings page either a major or minor tab"
^XmMAJOR
Save the part, and add it to the shape part's settings notebook by changing the settingsPageNames class method in MyShape.
settingsPageNames
"Add a new page to the settings notebook"
^(super settingsPageNames
add: MyShapeSettingsView;
yourself)
This method will add a new Shape page to the end of the settings notebook.
Adding help to the page
You can add help to this new settings page by adding two more class methods to MyShape, which specify the name of the help file and the help topic ID for the page:
abtSettingsViewHelpFile
"answer the name of the help file"
^'abtsamp'
abtSettingsViewHelpTopicId
"answer the topic id in the help file"
^'5'
Move both of these methods to MyEditSamplePartsApp.
Test your work by opening the settings of a shape part. Select rectangle or triangle from the drop-down list, and the shape part is displayed with the new appearance.
Last modified date: 06/12/2018