Dynamic change of text in diagram view
Preview released
This function and the API used in this function have been released in advance. We do not guarantee the quality at this time, so please use it at your own risk. Also, please note that these specifications are subject to change without notice.
Overview
You can change the string displayed as text on the diagram view to a string that is dynamically determined based on the state of the model, etc., instead of the value of the string field. You can also parse the entered string and update the model's field values as you edit the text on the diagram view.
The following implementation is required to achieve dynamic text modification:
- Implementation of callback function
- Implementation of callback function registration process
Implementation of callback function
Implements a callback function for dynamic text changes. There are the following types of callback functions:
- Text value acquisition/setting callback function
The following describes the implementation of each callback function.
Get text value callback function
Callback function signature
string get_TextValueFunction (IShape shape, TextTypes type, string textPath, IModel model)
Callback function call timing
When displaying text
For details, refer to the description of the argument getter of IViewDefinitions.RegisterTextValueCallback Method.
Text value setting callback function
Callback function signature
string set_TextValueFunction (IShape shape, TextTypes type, string textPath, IModel model)
Callback function call timing
When editing text in the UI
For details, refer to the description of the argument setter of IViewDefinitions.RegisterTextValueCallback Method.
Precautions when implementing the setting callback function
Setting text values When implementing a callback function (setter), there are two things to keep in mind:
Text editing on diagram
Setting text value The text value passed to the callback function is the string displayed on the diagram view, not the original value set in the model field (hereinafter referred to as the model value). .. If the string displayed on the diagram view has been modified by the Get Text Value callback function, the modified string will be passed. Therefore, when changing the value of the model with the text value setting callback function, it is necessary to consider the change by the text value acquisition callback function.
Applying the text value setting callback function multiple times
Setting the text value The callback function is called every time the text edit is confirmed. Implement the text value setting callback function in case it is called multiple times.
Implementation of callback function registration process
Implement the callback function registration process in the public method Activate
of the main class that implements IExtention.
Activate
method: Callback function registration
API used for registration process
Target Callback Function Registration API Shape IViewDefinitions.RegisterGetStyleCallback Method Text IViewDefinitions.RegisterGetTextStyleCallback Method Compartment Item IViewDefinitions.RegisterGetCompartmentItemTextStyleCallback Method Text Value (Title/Label) IViewDefinitions.RegisterTextValueCallback Method Text value (compartment item) IViewDefinitions.RegisterCompartmentItemTextValueCallback method
For details, refer to each method of IViewDefinitions Interface.