inherit static method
This static function declares that a class (constructor function) derives from another class -- but please note that most classes do not support inheritance. Do not call this function when your class is defined using an ES2015 or TypeScript "class" declaration.
Because you must not modify the prototypes for the GoJS classes, in order to override methods you need to define a new class that inherits from a predefined class. You can then modify the prototype of your derived class.
Typical usage is:
function BaseClass() {
this._total = 0;
}
public increment(x) {
this._total += x;
}
function DerivedClass() {
this._anotherProperty = "";
}
go.Diagram.inherit(DerivedClass, BaseClass);
DerivedClass.prototype.someMethod = ...;
Note that most classes do not support inheritance. Currently you can only inherit from Layout, Tool, CommandHandler, and Link or their subclasses. When you override a method, you must strongly consider calling the base method. Please read the Introduction page on Extensions for how to override methods and how to call a base method.
The call to Diagram.inherit
should be made immediately after defining the subclass constructor function
and before defining any new methods or overriding any base class methods.
You must not call this static function more than once on a derived class, or at all on a class defined using an ES2015 or TypeScript class declaration.
The need for subclassing is greatly diminished by the presence of a number of properties that have functional values. Setting such a property to a function will cause that function to be called as if it were an event handler for that particular object. Example properties include: GraphObject#click, GraphObject#mouseEnter, Part#layerChanged, Node#treeExpandedChanged, LinkingBaseTool#linkValidation, CommandHandler#memberValidation, TextEditingTool#textValidation.
Implementation
static void inherit(
_i2.Function derivedclass,
_i2.Function baseclass,
) {
_i4.callMethod(
_declaredDiagram,
'inherit',
[
derivedclass,
baseclass,
],
);
}