Active and Displayed Layer

<< Click to Display Table of Contents >>

Navigation:  Programming > Move cursor / select text >

Active and Displayed Layer

The current textlayer can be read and modified with the property ActiveText.

 

This property uses a reference to an object of the class TWPRTFDataBlock.

 

To put the cursor into the header text of an document you can use this code:

 

 WPRichText1.ActiveText := WPRichText1.HeaderFooter.Get(wpIsHeader, wpraOnAllPages);

 WPRichText1.SetFocus;

 

 move_cursor_in_header

 The cursor will appear in the header area. The text can be entered by the user of by program code.

 

To move the cursor back into the body text use this:

 

 WPRichText1.ActiveText := WPRichText1.BodyText;

 

This technique works for header and footer and with WPTools Premium also for text boxes and foot-notes.

 

 

It is also possible to change the text block which is currently displayed by the editor.

 

This is done using the property DisplayText. Usually this property references the BodyText, but if the program selects a different layer, only that layer will be displayed. If that layer should also be the current, the one which is currently being edited, ActiveText must be also modified:

 

 WPRichText1.DisplayedText := WPRichText1.HeaderFooter.Get(wpIsHeader,wpraOnAllPages);

 WPRichText1.ActiveText := WPRichText1.DisplayedText;

 WPRichText1.SetFocus;

 

 display_layer_only        

 

The most important property of the TWPRTFDataBlock class is FirstPar. That references the first paragraph which is used by this layer. It also contains functions to add text and tables.