Click or drag to resize

IHasContextMenuUpdateContextMenu Method

A callback which is called every time the module's context menu items need to update.

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
void UpdateContextMenu()
Request Example View Source
Remarks

When a part needs to update its context menu, it must not be doing it in the methods other this one. By doing the update in a single method, the part ensures there will be a consistency.

It's very implementation dependent when and why the update is needed. However, at the very least this callback must be called from the OnLoad method to let the module to update the state and the titles.

The method implemenation must expect to be called at any arbitrary moment of the module's life. If there are members that can be null, then they must be checked in this method to not throw an NPE. A special attention should be paid in the implementations that depend on the other modules since this method can get called when they are not initialized or created yet.

Unless the implementing class is sealed, the method must be declared as virtual. The descendants may want to react on the callback as well.

See Also