Protecting Text
You can mark a selection of content in a JadeRichText control as being protected. Protected text cannot be changed by users.
The setTextProtection method enables you to mark a content of a JadeRichText control from the position specified in the start parameter through to the length specified in the length parameter as protected or unprotected, by setting the protected parameter to true or false, respectively.
The getTextProtection method returns the protection state of text from the position specified in the start parameter through to the length specified in the length parameter. The return value indicates if the text is protected, unprotected, or contains a mixture of protected and unprotected text. The return values are represented by the JadeRichText class constants listed in the following table.
Constant |
Integer Value |
Description |
TextProtection_Set |
1 |
All text in the specified range is protected |
TextProtection_NotSet |
0 |
No text in the specified range is protected |
TextProtection_Mixed |
#80000000 |
Mixture of protected and unprotected text |
The protected event method is raised whenever a user attempts to alter in any way (for example, to insert, delete, or change the size of the font) text that is marked as protected. Your logic can determine if changes the rich text control should be allowed. Set the value of the allowChange parameter in the protected event method to true to allow the changes or to false if changes cannot be made to text in the control. The values of the start and length parameters indicate the block of text that the user is attempting to change. If you do not implement the protected event method on a specific control, any attempt to alter protected text is ignored.
In JADE, you can set or clear text protection only via logic (that is, by calling the setTextProtection method). Protected text in rich text format created externally to JADE and loaded into the JadeRichText control is honored by JADE.
When you call the setTextProtection method with the protected parameter set to true on protected text, the protected event is not raised.