Hello Mike,
following are the necessary modifications in the component created from the Text Editor template to display the # sign instead of the real text. Normally, the entered text is stored in the Text view existing within the component. The modification stores now the text in a new variable. The Text view itself will store and display only the corresponding count of # signs.
I hope it helps you further. Please follow the steps precisely to avoid errors.
Best regards
Paul Banach
Step 1: Per default, the Text Editor displays the readable string Text. Select the Text view and adapt its property String to be initialized with the string "####\n" (incl. the both quote signs) as shown below:
Step 2: Add a new variable to the Text Editor component. Name it e.g. content. The variable will be used to store the real text.
Step 3: Ensure the variable is declared with type string.
Step 4: Per default, the Text Editor displays the string Text. Ensure the variable's default value is "Text\n" too (incl. the quote signs). Following is the resulting variable with its type and initialization expression from the above steps 2-4:
Step 5: Select and delete the both members NewlineKeyHandler, onNewlineKey. These members take care of the line break. This will not work with the here described approach. Following are the members to delete:
Step 6: Open the method OnSetString and modify following code:
/* OLD CODE */
Text.String = str + "\n";
/* NEW CODE */
content = str + "\n";
Text.String = string( '#', content.length - 1 ) + '\n';
Step 7: Open the method OnGetString and modify following code:
/* OLD CODE */
var string str = Text.String;
/* NEW CODE */
var string str = content;
Step 8: Open the method onCharacterKey and modify following code:
/* OLD CODE */
Text.String = Text.String.insert( str, caretIndex );
/* NEW CODE */
content = content.insert( str, caretIndex );
Text.String = string( '#', content.length - 1 ) + '\n';
Step 9: Open the method onDeleteKey and modify following code:
/* OLD CODE 1 */
if ( caretIndex >= ( Text.String.length - 1 ))
/* NEW CODE 1 */
if ( caretIndex >= ( content.length - 1 ))
/* OLD CODE 2 */
var char ch = Text.String[ caretIndex ];
/* NEW CODE 2 */
var char ch = content[ caretIndex ];
/* OLD CODE 3 */
Text.String = Text.String.remove( caretIndex, count );
/* NEW CODE 3 */
content = content.remove( caretIndex, count );
Text.String = string( '#', content.length - 1 ) + '\n';
Step 10: Open the method onBackspaceKey and modify following code:
/* OLD CODE 1 */
var char ch = Text.String[ caretIndex - 1 ];
/* NEW CODE 1 */
var char ch = content[ caretIndex - 1 ];
/* OLD CODE 2 */
Text.String = Text.String.remove( caretIndex - count, count );
/* NEW CODE 2 */
content = content.remove( caretIndex - count, count );
Text.String = string( '#', content.length - 1 ) + '\n';
Thats all ... I hope.