Main Index : Reference :

PluginKey


Description

A plugin key class.

Definition

class PluginKey : BaseKey
{
public:
  PluginKey();
  
  [int] GetID() = 0;

  [bool] Init();
  [bool] Edit();

  [bool] Copy([PluginKey] dest);
  [bool] Save([HyperFile] hf);
  [bool] Load([HyperFile] hf);

  [bool] Message([int] type, [VariableChanged,BaseContainer] data);
}

Explanation

A class to derive plugin keys from.

Members

GetID()

[int] GetID() = 0;

Should return the id of the plugin. Must be overloaded in derived classes.


Init()

[bool] Init();

Called when a key is created. Overload this function if there are any variables or container values that need to be initialized. Returns TRUE if everything is OK.

Edit()

[bool] Edit();

Called when the user wants to edit the key. Normally one should then display a dialog with old settings, allowing the user to change them. The key data should be stored in the key's container or in custom variables. Return TRUE if anything was edited. If this function isn't overloaded, trying to edit the key does nothing.


Copy( dest )

[bool] Copy([PluginKey] dest);

This function must be overloaded if one wants to use custom variables in the derived key (i.e. not only the container). The function should copy any custom variables from this to dest and return TRUE. Otherwise the custom variables are lost when C4D wants to copy the key.

Save( hf )

[bool] Save([HyperFile] hf);

This function must be overloaded if one wants one's custom variables to be saved to disk. Use the HyperFile object that C4D sends to the function, hf, to save all of your variables and return TRUE.

Tips: It might be a good idea to use the first field in the HyperFile to save a version number for the plugin. Otherwise future versions of the plugin, with possibly different variables, won't know how to load the old key's data.

Load( hf )

[bool] Load([HyperFile] hf);

This function must be overloaded to load saved variables from disk. Load them from the HyperFile object in the same order as they were stored by Save() and return TRUE.


Message( type, data )

[bool] Message([int] type, [VariableChanged,BaseContainer] data);

Overload this function to be able to receive messages, like MSG_POINTS_CHANGED.