Difference between revisions of "PrF UG classes replace superclass"
Line 57: | Line 57: | ||
See [[PrF_UG_classes_jump_to_superclass|Jumping to a Different Superclass]] | See [[PrF_UG_classes_jump_to_superclass|Jumping to a Different Superclass]] | ||
for more information.) | for more information.) | ||
− | Note that the [[PrF_UG_classes_template_slot_pane|Template Slots | + | Note that the [[PrF_UG_classes_template_slot_pane|Template Slots pane]] |
for <b>Columnist</b> includes slots it inherits from <b>Employee</b>. | for <b>Columnist</b> includes slots it inherits from <b>Employee</b>. | ||
</p> | </p> |
Revision as of 15:24, October 26, 2008
Replacing a Superclass
You can move a class to a different superclass, using drag-and-drop in the Class Browser. This will remove the class from one superclass and make it a subclass of another superclass. Note that when you replace the superclass of a class, the class will often lose and gain inherited slots.
Moving a Class
To move a class:
Select the class you want to move. If the class has more than one superclass, select the view of the class that appears under the superclass you want to replace.
Hold down the mouse button and drag the class on top of the new superclass.
Release the mouse. The subclass will no longer be under the original superclass, but will now be located under the new superclass. Note that the slots of the moved class will automatically change to reflect the inheritance from its new superclass.
You can also add a superclass by holding down the Ctrl (Cmd) key while you drag.
Example
The following example shows how to make Columnist inherit from Employee, rather than the class Person.
Highlight Columnist in the Class Browser. Because Columnist has more than one superclass, you must make sure to select the copy of Columnist that is under Employee. (When a class has more than one superclass, you can use the Superclasses pane to select the copy that you want. See Jumping to a Different Superclass for more information.) Note that the Template Slots pane for Columnist includes slots it inherits from Employee.
Hold down the mouse button and drag Columnist on top of the new superclass Person.
Release the mouse button to drop the class. Person is outlined and the Class Browser redisplays to show the new hierarchy. The dragged class and all of its subclasses, if any, will be moved from the original superclass to the new superclass.
If you highlight Columnist after it has been repositioned, you will see that some of the slots it had before are now missing. These were the slots it inherited from Employee.